1. No more
One of our controllers still had the old-fashioned `before_filter` and we encountered the following error while booting up
This is because `before_filter` and
undefined method 'before_filter' before_filter has been deprecated in Rails 5.0 and removed in 5.1.
after_filterare deprecated from Rails 5.0.0 onwards. As you might have guessed, changing from
before_actionis the solution here.
We saw the following deprecation warning in our logs after the update
halt_callback_chains_on_return_false is deprecated
From Rails 5.0x, the callback chain is not halted when a before callback returns false. We need to use
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 = falsefrom
config/initializers/new_framework_defaults.rbto get rid of the warning.
3. Passing a class to the
One of the deprecation warnings after the update was,
class_name is deprecated
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 .]]>