gpt4 book ai didi

ruby-on-rails - #
转载 作者:行者123 更新时间:2023-12-04 07:34:21 25 4
gpt4 key购买 nike

我有 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'

我坚持这个。我用谷歌搜索它,但没有帮助。

最佳答案

在您应用的 config/applications.rb 中添加此内容

config.api_only = false

关于ruby-on-rails - #<ActionDispatch::Request 的未定义方法 `flash',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8855060/

25 4 0

Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com