【问题标题】:resource_controller get rid of setting flash notice?resource_controller 摆脱设置 flash 通知?
【发布时间】:2009-09-03 07:11:35
【问题描述】:

我在这里说的是 rails resource_controller gem 插件:

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

【问题讨论】:

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


    【解决方案1】:

    我不使用那个特定的 gem,但我认为这应该可以工作。

    在您的应用程序控制器中:

    def set_xhr_flash
      flash.discard if request.xhr?
    end
    

    然后确保您将其称为after_filter

    after_filter :set_xhr_flash
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-02-22
      • 1970-01-01
      • 2017-04-27
      • 2016-11-18
      • 1970-01-01
      • 1970-01-01
      • 2019-02-03
      相关资源
      最近更新 更多