2009-03-25 7 views
0

私のRailsアプリはローカルで正常に動作します。しかし、私は、サーバー上で、生産モードに入れたら、私はこのエラーを取得:テンプレートエラー

ActionView::TemplateError (undefined method `each' for nil:NilClass) on line #7 of app/views/admin/confirm.rhtml: 
4: <br>Description: 
5: <br><%= @description %> 
6: <br>Features: 
7: <% @features.each do |feature| %> 
8:  <br><%= feature.humanize %> 
9: <% end %> 
10: <br>Role data: 

    app/views/admin/confirm.rhtml:7 
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/renderable.rb:39:in `send' 
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/renderable.rb:39:in `render' 
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/template.rb:73:in `render_template' 
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/base.rb:256:in `render' 
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/base.rb:367:in `_render_with_layout' 
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/base.rb:254:in `render' 
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1174:in `render_for_file' 
    /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:896:in `render_without_benchmark' 

誰もが、それが何を意味するのか任意のアイデアがありますか?

編集:OK @featuresがnilであることがわかりました。しかし、私はそれがどのように分かっていません。私のcreateアクションでは私が持っている:

flash[:name] = params[:name] 
flash[:description] = params[:description] 
flash[:role_data] = params[:role_data] 
flash[:user_data] = params[:user_data] 
flash[:features] = params[:features] 
flash[:theme] = params[:theme] 
redirect_to :action => "confirm"  

はその後、私の確認アクションで私が持っている:

def confirm 
    @title = "Create a new simulation" 
    @features = flash[:features] 
    @name = flash[:name] 
    @description = flash[:description] 
    @role_data = flash[:role_data] 
    @user_data = flash[:user_data] 
    @theme = flash[:theme] 
    flash.keep 
    end 
+0

UHGアップフラッシュのものとは何ですか? Wha .. –

+0

オブジェクトをビューに送信する前に検査する必要があります。もう一度、フラッシュのものは何ですか? :O – Chirantan

答えて

1

あなた@featuresインスタンス変数はそのインスタンスのnilです。

3

セッションオブジェクトを使用して、アクション間でデータをやり取りしてください。 Flashは、データではなく、アクション間でメッセージを渡すためのものです。

0

flash.keepredirect_toを使用していて、renderを使用していないため、作成アクションに入れる必要があると思います。 ActionController::Flash::FlashHashから

When you need to pass an object to the current action, you use now, and your object will vanish when the current action is done.

Entries set via now are accessed the same way as standard entries: flash[‘my-key’].

関連する問題