0
私は、ユーザがURLパラメータを介してフォーマットを渡すことを可能にするスクリプトを書いています。私は必要に応じてJSONとXMLを動作させていますが、YAMLを動作させることはできません。何らかの理由でRails 3レンダリングの問題
case params[:format]
when "xml" then respond_with(@labels)
when "json" then respond_with(@labels_hash.to_json)
when "yaml" then render :text => @labels_hash.to_yaml
end
私は私のスクリプトファイルをダウンロード強制しようとし、その後、私のURLでformat=yaml
を渡すとき。これが起こる理由は何ですか?
ワーキングコード:
case params[:format]
when "xml" then respond_with(@labels)
when "json" then respond_with(@labels_hash.to_json)
when "yaml" then respond_with(@labels_hash) do |format|
format.yaml { render :text => @labels_hash.to_s }
end
end
私はそれを試してみましたが、まだ、ファイルをダウンロードし、強制しようとしています。 – dennismonsewicz
私はそれをcURL呼び出しを使って動作させました。私は作成したYAMLをブラウザで表示しようとしていましたが、ブラウザがYAML MIMEタイプの解釈方法を知らないとは思わなかった – dennismonsewicz