0

在我的 RoR 应用程序中,我使用“通知”和“警报”传递闪存消息。但是,例如,当我尝试像 flash["warning"] 一样传递时,我收到:undefined local variable or method warning'

我该怎么做才能创建一个传递“警告”值的闪存消息?

代码:

#app/controllers/users/passwords_controller.rb
class Users::PasswordsController < Devise::PasswordsController
  def create
    user = params["user"]

    if User.find_by_email(user["email"]).nil?
      set_flash_message(:testing, :email_not_found) if is_navigational_format?
      redirect_to root_path
    else
      self.resource = resource_class.send_reset_password_instructions(user)

      if successfully_sent?(resource)
        respond_with({}, :location => after_sending_reset_password_instructions_path_for(resource_name))
      else
        respond_with(resource)
      end
    end
  end

  protected

  def after_sending_reset_password_instructions_path_for(resource_name)
    root_path
  end
end

#app/views/landing/index.html.erb
.
.
<h5><%= testing %></h5>

有什么帮助吗?谢谢!

4

1 回答 1

0

尝试使用符号。flash[:warning] = "XYZ"例如。

于 2013-10-12T14:27:56.810 回答