Template error


my Rails app works fine locally. But once I put it on a server and in production mode, I get this error:

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:

   /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'

Anyone have any idea what it means?

EDIT: OK I found out @features is nil. But I don't know how it is. In my create action I have:

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"

Then in my confirm action I have:

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]
By : alamodey


I think you need to put flash.keep in the create action since you're using redirect_to and not render.

From 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’].

By : Sam Coles

Your @features instance variable is nil for that instance.

By : nitecoder

This video can help you solving your question :)
By: admin