Fix compatibility mistakes with ActiveRecord

This commit is contained in:
Yehuda Katz 2011-12-07 16:33:28 -08:00
parent 15abccdbeb
commit 8bdb7da272
2 changed files with 4 additions and 4 deletions

View File

@ -198,8 +198,8 @@ module ActiveModel
columns = klass.columns_hash
attrs = _attributes.inject({}) do |hash, (name,key)|
column = columns[name]
hash.merge key => column[:type]
column = columns[name.to_s]
hash.merge key => column.type
end
associations = _associations.inject({}) do |hash, association|
@ -212,7 +212,7 @@ module ActiveModel
# The model class associated with this serializer.
def model_class
name.sub(/Serializer$/, '')
name.sub(/Serializer$/, '').constantize
end
# Define how associations should be embedded.

View File

@ -557,7 +557,7 @@ class SerializerTest < ActiveModel::TestCase
Class.new do
class << self
def columns_hash
{ :name => { :type => :string }, :age => { :type => :integer } }
{ "name" => Struct.new(:type).new(:string), "age" => Struct.new(:type).new(:integer) }
end
def reflect_on_association(name)