aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/result.rb
diff options
context:
space:
mode:
authorMichael Probber <michael@probber.com>2015-04-07 10:42:57 -0400
committerMichael Probber <michael@probber.com>2015-04-17 14:11:16 -0400
commit21e448b5a5ab4dec6fd129f4eaba971d46a12bb1 (patch)
tree6683f2f32a6f567c155fc08bea646f80c0f09acb /activerecord/lib/active_record/result.rb
parent1881a7715d0bf2e3d0c30f189051d727dd65e6ff (diff)
downloadrails-21e448b5a5ab4dec6fd129f4eaba971d46a12bb1.tar.gz
rails-21e448b5a5ab4dec6fd129f4eaba971d46a12bb1.tar.bz2
rails-21e448b5a5ab4dec6fd129f4eaba971d46a12bb1.zip
Errors can be indexed with nested attributes
`has_many` can now take `index_errors: true` as an option. When this is enabled, errors for nested models will be returned alongside an index, as opposed to just the nested model name. This option can also be enabled (or disabled) globally through `ActiveRecord::Base.index_nested_attribute_errors` E.X. ```ruby class Guitar < ActiveRecord::Base has_many :tuning_pegs accepts_nested_attributes_for :tuning_pegs end class TuningPeg < ActiveRecord::Base belongs_to :guitar validates_numericality_of :pitch end ``` - Old style - `guitar.errors["tuning_pegs.pitch"] = ["is not a number"]` - New style (if defined globally, or set in has_many_relationship) - `guitar.errors["tuning_pegs[1].pitch"] = ["is not a number"]` [Michael Probber, Terence Sun]
Diffstat (limited to 'activerecord/lib/active_record/result.rb')
0 files changed, 0 insertions, 0 deletions