誰かがXMLテンプレートのレンダリングとsend_dataを手伝ってくれますか?
私はコントローラーを持っています:
def show
@calculation = Calculation.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @calculation }
format.xml {send_data( :partial=>show.xml.erb, :filename => "my_file.xml" ) }
format.pdf { render :format=>false}
end
end
しかし、「スタックレベルが深すぎる」というエラーがたくさんあります
使用する場合
{send_data( @calculation, :filename => "my_file.xml" ) }
XMLファイルを取得しましたが、テンプレートからは取得しません...
編集: 私は方法があります!
format.xml do
stream = render_to_string(:template=>"calculations/show" )
send_data(stream, :type=>"text/xml",:filename => "test.xml")
end
そして、すべてが正しく動作します!