【发布时间】:2011-03-24 11:31:01
【问题描述】:
我正在使用 Rails 3,并且我有一个 ajax 表单(即 :remote => true),它在我的控制器上执行“插入”操作。
我希望用户留在索引页面上,但能够显示控制器中“插入”操作设置的闪存消息。
目前我的“插入”动作是这样的:
def insert
begin
# perform insert of stuff
flash[:success] = "Successfully..."
rescue
flash[:error] = "failed ..."
end
render :nothing => true
end
这允许提交表单(在 index.html.erb 上)并将用户保留在该页面上,但不会显示任何 Flash 消息。如何让 Flash 消息出现? (猜测它与渲染有关:没有什么东西,但没有它,我会在服务器日志中收到“缺少模板”错误)。
【问题讨论】:
标签: ajax ruby-on-rails-3