aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/belongs_to_association.rb
Commit message (Collapse)AuthorAgeFilesLines
* Adds title to activerecord/lib/active_record/associations/*Rizwan Reza2010-06-161-0/+1
|
* Remove whitespace.Emilio Tagua2009-08-191-2/+2
|
* Add primary_key option to belongs_to associationSzymon Nowak2009-07-151-4/+22
| | | | | | [#765 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* Providing support for :inverse_of as an option to associations.Murray Steele2009-05-041-1/+11
| | | | | | | | | | | | | | | | | | | | | | You can now add an :inverse_of option to has_one, has_many and belongs_to associations. This is best described with an example: class Man < ActiveRecord::Base has_one :face, :inverse_of => :man end class Face < ActiveRecord::Base belongs_to :man, :inverse_of => :face end m = Man.first f = m.face Without :inverse_of m and f.man would be different instances of the same object (f.man being pulled from the database again). With these new :inverse_of options m and f.man are the same in memory instance. Currently :inverse_of supports has_one and has_many (but not the :through variants) associations. It also supplies inverse support for belongs_to associations where the inverse is a has_one and it's not a polymorphic. Signed-off-by: Murray Steele <muz@h-lame.com> Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* Add special AssociationReflection methods for creating association objects, ↵Hongli Lai (Phusion)2008-09-091-2/+2
| | | | | | | | and modify the code base to use those methods instead of creating association objects directly. This allows plugins to hook into association object creation behavior. [#986 state:resolved] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* Fix file permissionsTarmo Tänav2008-07-311-0/+0
| | | | Signed-off-by: Joshua Peek <josh@joshpeek.com>
* Added :select option to has_one and belongs_to, remove unused :order option ↵josevalim2008-05-241-2/+3
| | | | | | | on belongs_to. Signed-off-by: Michael Koziarski <michael@koziarski.com> [#241 state:resolved]
* Introduce the :readonly option to all associations. Records from the ↵Jeremy Kemper2008-02-131-1/+2
| | | | | | association cannot be saved. Closes #11084. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8864 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Make sure that belongs_to counter decrements when assigning nil Closes ↵Michael Koziarski2008-01-261-1/+1
| | | | | | #10804 [jeanmartin] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8735 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Backed out of new_record? to new? transformation as it would screw up ↵David Heinemeier Hansson2006-09-051-3/+3
| | | | | | existing models that did boolean calls on "new" attributes [DHH] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5018 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Deprecated ActiveRecord::Base.new_record? in favor of ↵David Heinemeier Hansson2006-09-051-3/+3
| | | | | | ActiveRecord::Base.new? (old version still works until Rails 2.0) [DHH] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5017 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Use association's :conditions when eager loading. [jeremyevans0@gmail.com] ↵Rick Olson2006-03-161-1/+1
| | | | | | closes #4144 git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3897 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Fix counter cache setting in belongs-to proxyJamis Buck2006-03-091-1/+1
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3828 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Make counter cache work when replacing an association (closes #3245). Thanks ↵Jamis Buck2006-03-041-0/+11
| | | | | | for the patch! git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3762 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Added preliminary support for join models [DHH] Added preliminary support ↵David Heinemeier Hansson2005-12-031-42/+16
| | | | | | for polymorphic associations [DHH] Refactored associations to use reflections to get DRYer, beware, major refactoring -- double check before deploying anything with this (all tests pass, but..) git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3213 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Work-in progress for providing better join model support and polymorphic ↵David Heinemeier Hansson2005-12-021-4/+0
| | | | | | associations git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3209 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Added :include as an option for association declarations [DHH]David Heinemeier Hansson2005-11-061-2/+6
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2898 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Fix errors caused by assigning a has-one or belongs-to property to itselfJamis Buck2005-10-131-1/+1
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2562 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Fixed that the create_x method from belongs_to wouldn't save the association ↵David Heinemeier Hansson2005-09-201-2/+2
| | | | | | properly #2042 [Florian Weber] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2279 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Fixed saving a record with two unsaved belongs_to associations pointing to ↵Jamis Buck2005-09-201-0/+5
| | | | | | the same object #2023 [Tobias Luetke] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2278 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Added support for calling constrained class methods on has_many and ↵David Heinemeier Hansson2005-07-221-2/+11
| | | | | | has_and_belongs_to_many collections #1764 [Tobias Luetke] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1894 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Moved build_association and create_association for has_one and belongs_to ↵David Heinemeier Hansson2005-04-121-1/+0
| | | | | | out of deprecation as they work when the association is nil unlike association.build and association.create, which require the association to be already in place #864 git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1146 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Fixed that the belongs_to and has_one proxy would fail a test like 'if ↵David Heinemeier Hansson2005-01-181-17/+1
| | | | | | project.manager' -- this unfortunately also means that you can't call methods like project.manager.build unless there already is a manager on the project #492 [Tim Bates] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@456 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* belongs_to association should always honor a present foreign key and ↵David Heinemeier Hansson2005-01-171-1/+5
| | | | | | condition interpolation should also be possible on belongs_to git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@433 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Added support for associating unsaved objects #402 [Tim Bates]David Heinemeier Hansson2005-01-151-0/+70
Added replace to associations, so you can do project.manager.replace(new_manager) or project.milestones.replace(new_milestones) #402 [Tim Bates] Added build and create methods to has_one and belongs_to associations, so you can now do project.manager.build(attributes) #402 [Tim Bates] Fixed that Base#== wouldn't work for multiple references to the same unsaved object #402 [Tim Bates] Added that if a before_* callback returns false, all the later callbacks and the associated action are cancelled. If an after_* callback returns false, all the later callbacks are cancelled. Callbacks are generally run in the order they are defined, with the exception of callbacks defined as methods on the model, which are called last. #402 [Tim Bates] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@417 5ecf4fe2-1ee6-0310-87b1-e25e094e27de