Skip to content

Commit

Permalink
Add more explicit guidance on how to fix callback deprecations
Browse files Browse the repository at this point in the history
This deprecation warning message will be more useful if it indicates what the string was doing — being eval'd — and what the non-deprecated options for callback conditionals are.
  • Loading branch information
ragesoss committed Jun 23, 2017
1 parent ab0e455 commit c79416a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions activesupport/lib/active_support/callbacks.rb
Expand Up @@ -662,8 +662,10 @@ def set_callback(name, *filter_list, &block)

if options[:if].is_a?(String) || options[:unless].is_a?(String)
ActiveSupport::Deprecation.warn(<<-MSG.squish)
Passing string to :if and :unless conditional options is deprecated
and will be removed in Rails 5.2 without replacement.
Passing string to be evaluated in :if and :unless conditional
options is deprecated and will be removed in Rails 5.2 without
replacement. Pass a symbol for an instance method, or a lamdba,
proc or block, instead.
MSG
end

Expand Down

0 comments on commit c79416a

Please sign in to comment.