How to change the following method to use tap
to stop the warnings like
DEPRECATION WARNING: Object#returning has been deprecated in favor of Object#tap. (called from full_messages at /Users/millisami/apps/pandahr/config/initializers/fix_active_model_full_message.rb:17)
:
ActiveModel::Errors.class_eval do
# Remove complicated logic
def full_messages
returning full_messages = [] do
self.each_key do |attr|
self[attr].each do |msg|
full_messages << msg if msg
end
end
end
end
end
In general you can replace the returning
line with this call to tap
:
[].tap do |full_messages|
However your method looks like it's equivalent to values.compact
, so you can just replace your code with that.
This warning message can occur if you upgrade old Rails 2 applications. Since the Rails Version 2.3.9 the Kernel#returning function has been replaced with Object#tap which is native to Ruby 1.8.7. Unfortunately this error often is caused by older plugins and gems. For me it helped to update the haml version from 2.0.x to 3.0.21, and the will_paginate version from 2.2.x to 2.3.15.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With