#<ActionDispatch::Request 的未定义方法`flash' [英] undefined method `flash' for #<ActionDispatch::Request
本文介绍了#<ActionDispatch::Request 的未定义方法`flash'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有关于 Ruby on Rails 3 的东西
I have stuff with Ruby on Rails 3
我试试这个简单的代码
def index
flash[:notice] = "ok"
respond_to do |format|
format.html # index.html.erb
end
end
它不起作用
NoMethodError in DashboardsController#index
undefined method `flash' for #<ActionDispatch::Request:0x7fee9329a9d0>
当我尝试
redirect_to :some_in, :notice => "ok"
在其他地方(在 some_controller.rb 中),然后在 .erb 中打印:notice我有同样的错误,未定义的方法`flash'
in other place (in some_controller.rb) and then print this :notice in .erb I have same error, undefined method `flash'
我被困在这个问题上.我用谷歌搜索过,但没有帮助.
I'm stuck on this. I used google to search for it but it does not help.
推荐答案
在你的应用的 config/applications.rb
中添加这个
In config/applications.rb
of your app add this
config.api_only = false
这篇关于#<ActionDispatch::Request 的未定义方法`flash'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文