Skip to content

Commit

Permalink
Ticket #2156 - Use foreign_key inflection uniformly
Browse files Browse the repository at this point in the history
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2394 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
jeremy committed Sep 28, 2005
1 parent 981763e commit db8f727
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*

* Use foreign_key inflection uniformly. #2156 [Blair Zajac <blair@orcaware.com>]

* model.association.clear should destroy associated objects if :dependent => true instead of nullifying their foreign keys. #2221 [joergd@pobox.com, ObieFernandez <obiefernandez@gmail.com>]

* Returning false from before_destroy should cancel the action. #1829 [Jeremy Huffman]
Expand Down
4 changes: 2 additions & 2 deletions activerecord/lib/active_record/associations.rb
Expand Up @@ -442,7 +442,7 @@ def belongs_to(association_id, options = {})

require_association_class(association_class_name)

association_class_primary_key_name = options[:foreign_key] || Inflector.underscore(Inflector.demodulize(association_class_name)) + "_id"
association_class_primary_key_name = options[:foreign_key] || association_class_name.foreign_key

association_accessor_methods(association_name, association_class_name, association_class_primary_key_name, options, BelongsToAssociation)
association_constructor_method(:build, association_name, association_class_name, association_class_primary_key_name, options, BelongsToAssociation)
Expand Down Expand Up @@ -599,7 +599,7 @@ def associate_identification(association_id, association_class_name, foreign_key
)
end

primary_key_name = foreign_key || Inflector.underscore(Inflector.demodulize(name)) + "_id"
primary_key_name = foreign_key || name.foreign_key

return association_id.id2name, association_class_name, primary_key_name
end
Expand Down

0 comments on commit db8f727

Please sign in to comment.