Commit b34b8904 by Ryan Bigg

Do not restore if attributes are frozen

This appears to be a Rails ~> 4.0.8 bug, which is seemingly fixed in Rails 4.1.
parent d0703231
......@@ -87,7 +87,12 @@ module Paranoia
def restore!(opts = {})
self.class.transaction do
run_callbacks(:restore) do
update_column paranoia_column, paranoia_sentinel_value
# Fixes a bug where the build would error because attributes were frozen.
# This only happened on Rails versions earlier than 4.1.
noop_if_frozen = ActiveRecord.version < Gem::Version.new("4.1")
if (noop_if_frozen && !@attributes.frozen?) || !noop_if_frozen
update_column paranoia_column, paranoia_sentinel_value
end
restore_associated_records if opts[:recursive]
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