2012-09-26 3 views
13

誰でもXMLテンプレートレンダリングとsend_dataを手伝ってもらえますか?Ruby on Rails 3.2.8で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 

をしかし、私は、私はXMLファイルを取得しますが、ないから

{send_data(@calculation, :filename => "my_file.xml") } 

を使用する場合は、「あまりにも深いスタックレベル」

と多くのエラーを持っています私のテンプレート...

編集:私は方法があります!

format.xml do 
    stream = render_to_string(:template=>"calculations/show") 
    send_data(stream, :type=>"text/xml",:filename => "test.xml") 
end 

すべて正常に動作します。 「未回答」フィルタからこの質問を削除するために、編集された質問本体からの回答をコピー

+0

あたり

format.xml do stream = render_to_string(:template=>"calculations/show") send_data(stream, :type=>"text/xml",:filename => "test.xml") end 

〜答えはあなたの全体のトレースを投稿してもらえますか? – sunnyrjuneja

+0

CalculationsControllerのSystemStackError#show スタックレベルが深すぎます Rails.root:C:/RubyStack-3.2.5-0/examplexml アプリケーショントレース|フレームワークトレース| {:偽形式=>レンダリング} しかし、唯一の画面、 format.xml:私は私のChromeで結果を持つことができる70 – Dmitry

+1

:フルトレース actionpack(3.2.5)のlib/action_dispatch /ミドルウェア/ reloader.rbダウンロードするファイルではありません – Dmitry

答えて

関連する問題