Rails 5 upgrade Halt callback config issue

已查看 188 次
跳至第一个未读帖子

Muhammad Ibraheem

未读,
2017年12月8日 03:24:442017/12/8
收件人 Ruby on Rails: Talk

I have recently upgraded from Rails 4.2 to 5.0.6 . I know about the change in callback halting using throw(:abort) instead of returning false. My problem is that I can't make the deprecation warnings go away.


DEPRECATION WARNING: Returning false in Active Record and Active Model callbacks will not implicitly halt a callback chain in Rails 5.1. To explicitly halt the callback chain, please use throw :abort instead.


I have made config/initializers/callback_terminator.rb file with following code


ActiveSupport.halt_callback_chains_on_return_false = false


but I am not still not able to get rid of the warning. Nor am I getting the expected behavior. If I return false from call back it stops the action.
It seems that this configuration is not being applied. I am experiencing this in both dev and test environments.


Is there something I am missing?

Muhammad Ibraheem

未读,
2017年12月8日 04:37:462017/12/8
收件人 Ruby on Rails: Talk
Any help will be highly appreciated.

nanaya

未读,
2017年12月8日 05:11:222017/12/8
收件人 rubyonra...@googlegroups.com
Hi,

On Fri, Dec 8, 2017, at 16:55, Muhammad Ibraheem wrote:
>
>
> I have made config/initializers/callback_terminator.rb file with
> following
> code
>
>
> ActiveSupport.halt_callback_chains_on_return_false = false
>
>

You need to remove the whole line, not just setting it to false.

Muhammad Ibraheem

未读,
2017年12月8日 10:29:202017/12/8
收件人 Ruby on Rails: Talk
Removing this line doesn't do anything and defaults to Old behavior.

Muhammad Ibraheem

未读,
2017年12月8日 10:30:112017/12/8
收件人 Ruby on Rails: Talk
I have confirmed that the file callback_terminator.rb  is being loaded properly.

Muhammad Ibraheem

未读,
2017年12月8日 10:59:282017/12/8
收件人 Ruby on Rails: Talk

I have tinkered with the problem. When I do add the config in config.after_initialize block it works.

    config.after_initialize do
      ActiveSupport.halt_callback_chains_on_return_false = false
    end

But it still doesn't work if I put it in an initializer file. Problem solved for me though.

nanaya

未读,
2017年12月8日 13:07:192017/12/8
收件人 rubyonra...@googlegroups.com
Hi,

On Sat, Dec 9, 2017, at 00:29, Muhammad Ibraheem wrote:
> Removing this line doesn't do anything and defaults to Old behavior.
>


Whoops sorry, I checked this on a 5.1 app which the option doesn't do
anything anymore.
回复全部
回复作者
转发
0 个新帖子