我的 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'
有人知道这意味着什么吗?
编辑:好的,我发现@features 为零。但我不知道情况如何。在我的创建动作中,我有:
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