Rails 5 upgrade Halt callback config issue

184 views
Skip to first unread message

Muhammad Ibraheem

unread,
Dec 8, 2017, 3:24:44 AM12/8/17
to 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

unread,
Dec 8, 2017, 4:37:46 AM12/8/17
to Ruby on Rails: Talk
Any help will be highly appreciated.

nanaya

unread,
Dec 8, 2017, 5:11:22 AM12/8/17
to 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

unread,
Dec 8, 2017, 10:29:20 AM12/8/17
to Ruby on Rails: Talk
Removing this line doesn't do anything and defaults to Old behavior.

Muhammad Ibraheem

unread,
Dec 8, 2017, 10:30:11 AM12/8/17
to Ruby on Rails: Talk
I have confirmed that the file callback_terminator.rb  is being loaded properly.

Muhammad Ibraheem

unread,
Dec 8, 2017, 10:59:28 AM12/8/17
to 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

unread,
Dec 8, 2017, 1:07:19 PM12/8/17
to 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.
Reply all
Reply to author
Forward
0 new messages