0
在我的RoR應用程序中,我使用「notice」和「alert」來傳遞Flash消息。 但是,當我嘗試像flash一樣傳遞[「warning」]時,例如,我收到:undefined local variable or method warning'
如何添加新的變量與設計的Flash消息?
我能做些什麼來創建傳遞'warning'值的flash消息?
代碼:
#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>
任何幫助嗎?謝謝!
沒有工作.. =/ – hugalves
你能展示一些更多的代碼嗎? – stevecross
完成!真的很奇怪,不工作.. – hugalves