1. No more before_filter
One of our controllers still had the old-fashioned `before_filter` and we encountered the following error while booting up
undefined method 'before_filter' before_filter has been deprecated in Rails 5.0 and removed in 5.1.
after_filter
are deprecated from Rails 5.0.0 onwards. As you might have guessed, changing from before_filter
to before_action
is the solution here.
2. halt_callback_chains_on_return_false
is deprecated
We saw the following deprecation warning in our logs after the update
ActiveSupport.halt_callback_chains_on_return_false= is deprecated and will be removed in Rails 5.2.
throw(:abort)
to explicitly halt callbacks
Though we had no return false in our callbacks, we still had to remove the line,
ActiveSupport.halt_callback_chains_on_return_false = false
from config/initializers/new_framework_defaults.rb
to get rid of the warning.
3. Passing a class to the class_name
is deprecated
One of the deprecation warnings after the update was,
Passing a class to the 'class_name' is deprecated and will raise an ArgumentError in Rails 5.2. It eagerloads more classes than necessary and potentially creates circular dependencies. Please pass the class name as a string:
This warning message was due to passing a class to `class_name` option when specifying associations – this is no longer recommended‘
- has_one :contact, class_name: UserContact + has_one :contact, class_name: 'UserContactpassing class name as a string is a standard now Happy Hacking ❤
PS: If you need any help in upgrading your rails version drop an email to us at [email protected] or [email protected] We will be more than happy to go through your system and give a free upgrade action plan and estimation .]]>