【发布时间】:2013-02-08 05:29:08
【问题描述】:
我正在尝试在成功提交表单后显示快速通知。在 Rails 中,我会在控制器中使用类似的东西:
:notice => "Youve submitted the form"
我遇到了Sinatra flash gem,并希望在重定向后显示一条 Flash 消息。我像这样安装了 gem 和设置:
myapp.rb:
require 'sinatra/flash'
enable :sessions
#form config
)}
redirect '/success' # this is the hook after my form submission
end
get('/success') do
flash[:success] = "Thanks for your email. I'll be in touch soon."
erb :index
end
所有发生的事情是我被重定向到没有 Flash 消息的索引页面。查看文档,这就是我需要做的所有事情。有没有人觉得有什么不同?
【问题讨论】:
-
我不确定,但您是否在 index.* 视图中添加了适当的代码?像 = flash
-
你能不能稍微扩展一下,不太清楚你的意思