method
build_record
v3.1.0 -
Show latest stable
-
0 notes -
Class: Association
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0
- 3.0.9
- 3.1.0 (0)
- 3.2.1 (0)
- 3.2.8 (0)
- 3.2.13 (0)
- 4.0.2 (0)
- 4.1.8 (0)
- 4.2.1 (0)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (0)
- 5.1.7 (0)
- 5.2.3 (0)
- 6.0.0 (0)
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (0)
- 7.1.3.4 (0)
- What's this?
build_record(attributes, options)
private
Hide source
# File activerecord/lib/active_record/associations/association.rb, line 233 def build_record(attributes, options) reflection.original_build_association_called = false record = reflection.build_association(attributes, options) do |r| r.assign_attributes( create_scope.except(*r.changed), :without_protection => true ) end if !reflection.original_build_association_called && (record.changed & create_scope.keys) != create_scope.keys # We have detected that there is an overridden AssociationReflection#build_association # method, but it looks like it has not passed through the block above. So try again and # show a noisy deprecation warning. record.assign_attributes( create_scope.except(*record.changed), :without_protection => true ) method = reflection.method(:build_association) if RUBY_VERSION >= '1.9.2' source = method.source_location debug_info = "It looks like the method is defined in #{source[0]} at line #{source[1]}." else debug_info = "This might help you find the method: #{method}. If you run this on Ruby 1.9.2 we can tell you exactly where the method is." end ActiveSupport::Deprecation.warn It looks like ActiveRecord::Reflection::AssociationReflection#build_association has been redefined, either by you or by a plugin or library that you are using. The signature of this method has changed. Before: def build_association(*options) After: def build_association(*options, &block)The block argument now needs to be passed through to ActiveRecord::Base#new when this method is overridden, or else your associations will not function correctly in Rails 3.2.#{debug_info} end record end