Skip to content

Commit

Permalink
Rails 4.2 has deprecated serialized_attributes
Browse files Browse the repository at this point in the history
* Use the new `type_for_attribute` method instead
  • Loading branch information
Ian Zabel committed Dec 24, 2014
1 parent f8f3e02 commit 698f06a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion lib/rails_admin/adapters/active_record/property.rb
Expand Up @@ -18,7 +18,7 @@ def pretty_name
end

def type
if model.serialized_attributes[property.name.to_s]
if serialized?
:serialized
else
property.type
Expand All @@ -44,6 +44,16 @@ def association?
def read_only?
false
end

private

def serialized?
if Rails.version < '4.2'
model.serialized_attributes[property.name.to_s]
else
model.type_for_attribute(property.name).class == ::ActiveRecord::Type::Serialized
end
end
end
end
end
Expand Down
Expand Up @@ -1017,7 +1017,7 @@ def color_enum
end

after do
Team.serialized_attributes.clear
Team.serialized_attributes.clear if Rails.version < '4.2'
Team.instance_eval { undef :color_enum }
end

Expand Down

0 comments on commit 698f06a

Please sign in to comment.