mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-24 14:56:50 +00:00
Fix compatibility mistakes with ActiveRecord
This commit is contained in:
parent
15abccdbeb
commit
8bdb7da272
@ -198,8 +198,8 @@ module ActiveModel
|
|||||||
columns = klass.columns_hash
|
columns = klass.columns_hash
|
||||||
|
|
||||||
attrs = _attributes.inject({}) do |hash, (name,key)|
|
attrs = _attributes.inject({}) do |hash, (name,key)|
|
||||||
column = columns[name]
|
column = columns[name.to_s]
|
||||||
hash.merge key => column[:type]
|
hash.merge key => column.type
|
||||||
end
|
end
|
||||||
|
|
||||||
associations = _associations.inject({}) do |hash, association|
|
associations = _associations.inject({}) do |hash, association|
|
||||||
@ -212,7 +212,7 @@ module ActiveModel
|
|||||||
|
|
||||||
# The model class associated with this serializer.
|
# The model class associated with this serializer.
|
||||||
def model_class
|
def model_class
|
||||||
name.sub(/Serializer$/, '')
|
name.sub(/Serializer$/, '').constantize
|
||||||
end
|
end
|
||||||
|
|
||||||
# Define how associations should be embedded.
|
# Define how associations should be embedded.
|
||||||
|
|||||||
@ -557,7 +557,7 @@ class SerializerTest < ActiveModel::TestCase
|
|||||||
Class.new do
|
Class.new do
|
||||||
class << self
|
class << self
|
||||||
def columns_hash
|
def columns_hash
|
||||||
{ :name => { :type => :string }, :age => { :type => :integer } }
|
{ "name" => Struct.new(:type).new(:string), "age" => Struct.new(:type).new(:integer) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def reflect_on_association(name)
|
def reflect_on_association(name)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user