1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #15689 from sgrif/sg-attribute-methods

Ensure we always define attribute methods
This commit is contained in:
Matthew Draper 2014-06-14 04:46:05 +09:30
commit 584498a61f
2 changed files with 9 additions and 0 deletions

View file

@ -262,6 +262,7 @@ module ActiveRecord
init_internals
initialize_internals_callback
self.class.define_attribute_methods
# +options+ argument is only needed to make protected_attributes gem easier to hook.
# Remove it when we drop support to this gem.
init_attributes(attributes, options) if attributes

View file

@ -69,6 +69,14 @@ class SerializationTest < ActiveRecord::TestCase
ActiveRecord::Base.include_root_in_json = original_root_in_json
end
def test_read_attribute_for_serialization_with_format_without_method_missing
klazz = Class.new(ActiveRecord::Base)
klazz.table_name = 'books'
book = klazz.new
assert_nil book.read_attribute_for_serialization(:format)
end
def test_read_attribute_for_serialization_with_format_after_init
klazz = Class.new(ActiveRecord::Base)
klazz.table_name = 'books'