美文网首页
Rails 5 does not halt callback c

Rails 5 does not halt callback c

作者: ysllllllllllyfe | 来源:发表于2016-10-31 10:36 被阅读0次

    Rails 升级到 5 以后,突然发现before_save的时候,return false 不生效了,Google一下,第一篇就是解决方案。

    Rails 5 does not halt callback chain when false is returned
    http://blog.bigbinary.com/2016/02/13/rails-5-does-not-halt-callback-chain-when-false-is-returned.html

    解决方案一,使用 throw(:abort) 来跳出代码
    
    解决方案二,修改配置,对应配置在initializers/new_framework_defaults.rb中
    ActiveSupport.halt_callback_chains_on_return_false = false
    值改为true
    

    相关文章

      网友评论

          本文标题:Rails 5 does not halt callback c

          本文链接:https://www.haomeiwen.com/subject/dkxputtx.html