Gary Weaver
2013-Dec-16 14:57 UTC
has_many doc inconsistency/missing info in upgrade doc related to dependent option behavior change from Rails 3 to 4
A team member just found the following out about an inconsistency in the Rails documentation. Although: https://github.com/rails/rails/pull/7188/files indicates for the dependent option: "When no option is given, the behaviour is to do nothing with the associated records when destroying a record." Which is consistent with the behavior, but in: https://github.com/rails/rails/blob/4b4aeabb3605bd0cbd7dde10c1d2ac990c65379a/activerecord/lib/active_record/associations.rb#L988 (in the rdoc for associations), it states: "The default strategy is :nullify (set the foreign keys to nil), except for has_many :through, where the default strategy is delete_all (delete the join records, without running their callbacks)." I think that last statement is a little unclear since it is no longer accurate in Rails 4, it seems. Magne on S.O. also noted this in the first comment of this answer: http://stackoverflow.com/a/16329482/178651 In addition, that might be helpful to mention somewhere in guides/source/upgrading_ruby_on_rails.md? I''m not sure how to summarize/clarify that behavior at the moment in associations.rb (would just removing the sentence about the default strategy be ok?) or in which places "dependent: :nullify" should be added to models to ensure similar behavior from Rails 3 to 4 for the upgrade doc. Any ideas? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/groups/opt_out.