Commit 400e03f6 by Sergey Alekseev

add deprecation warning for `.restore` with object

http://edgeguides.rubyonrails.org/4_2_release_notes.html#active-record-d
eprecations
> Deprecated passing Active Record objects to .find or .exists?. Call
id on the objects first.
Commits in Rails:
https://github.com/rails/rails/commit/d92ae6ccca3bcfd73546d612efaea01127
0bd270
https://github.com/rails/rails/commit/d35f0033c7dec2b8d8b52058fb8db495d4
9596f7
https://github.com/rails/rails/commit/c0609dd0f0f0de604ac1ffeffdf5e3e0e7
356b35
parent c0d8a2f8
......@@ -34,6 +34,11 @@ module Paranoia
alias :deleted :only_deleted
def restore(id, opts = {})
if ActiveRecord::Base === id
id = id.id
ActiveSupport::Deprecation.warn("You are passing an instance of ActiveRecord::Base to `restore`. " \
"Please pass the id of the object by calling `.id`")
end
Array(id).flatten.map { |one_id| only_deleted.find(one_id).restore!(opts) }
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment