resource_controller摆脱设置flash通知?

时间:2009-09-03 07:11:36

标签: ruby-on-rails ruby-on-rails-plugins

我在这里谈论rails resource_controller gem插件:

基本上当我做json格式时,我想完全抑制闪光通知,如果可能,尝试调用flash“”将失败,而调用flash [:notice] =“”看起来也不是很好。有更好的方法吗?

1 个答案:

答案 0 :(得分:0)

我不使用那个特定的宝石,但我认为无论如何都应该有效。

在ApplicationController中:

def set_xhr_flash
  flash.discard if request.xhr?
end

然后确保将其称为after_filter

after_filter :set_xhr_flash