aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations.rb
Commit message (Collapse)AuthorAgeFilesLines
* Suppress deprecation message to `has_and_belongs_to_many` only onceRyuta Kamizono2017-01-101-2/+2
| | | | | Passing a class to `has_and_belongs_to_many` show deprecation message three times. It is enough only once.
* `self.` is not needed when calling its own instance methodAkira Matsuda2017-01-051-1/+1
| | | | Actually, private methods cannot be called with `self.`, so it's not just redundant, it's a bad habit in Ruby
* Raise error when has_many through is defined before through associationChris Holmes2017-01-041-0/+10
| | | | | | | https://github.com/rails/rails/issues/26834 This change raises an error if a has_many through association is defined before the through association.
* [ci skip] Retouch some association wording.Kasper Timm Hansen2016-12-311-3/+4
| | | | | Trim some needless words off the lines and format the code sample like we'd write in the Rails source.
* [ci skip] Remove mention of GeneratedAssociationMethodsKasper Timm Hansen2016-12-311-4/+3
| | | | | Marked as private in 2afe5a1 and doesn't seem worth it to mention the module name here.
* Raise when a through association has an ambiguous reflection nameRafael Mendonça França2016-12-291-0/+15
|
* No need to nodoc private methodsAkira Matsuda2016-12-241-2/+2
|
* `eager_autoload` needs to be triggered for nested constants.Yves Senn2016-11-211-0/+5
| | | | | | | | | | | | | | | When `ActiveRecord::Associations.eager_load!` is called, it eager loads the `Preloader` but does not trigger a `eager_load!` on the `Preloader` itself. A eager loaded component is responsible to forward the `eager_load!` call to nested constants that make use of `eager_autoload` as well. This will also resolve the occasional `NameError` that we've observed in production: ``` NameError: uninitialized constant ActiveRecord::Associations::Preloader::BelongsTo ```
* Add missing `+` around a some literals.bogdanvlviv2016-10-271-1/+1
| | | | | | Mainly around `nil` [ci skip]
* Fix broken comments indentation caused by rubocop auto-correct [ci skip]Ryuta Kamizono2016-09-141-876/+876
| | | | | | All indentation was normalized by rubocop auto-correct at 80e66cc4d90bf8c15d1a5f6e3152e90147f00772. But comments was still kept absolute position. This commit aligns comments with method definitions for consistency.
* Fix broken heredoc indentation caused by rubocop auto-correctRyuta Kamizono2016-09-031-6/+6
| | | | | | All indentation was normalized by rubocop auto-correct at 80e66cc4d90bf8c15d1a5f6e3152e90147f00772. But heredocs was still kept absolute position. This commit aligns heredocs indentation for consistency.
* Use splat `options` hash for `has_and_belongs_to_many`Ryuta Kamizono2016-08-261-6/+1
| | | | For simplicity.
* Doc on scoped has_many, dependent: :destroyPhilip Nguyen2016-08-221-0/+6
| | | | | | | | | This is to close #26111 Developers need to be aware that `dependent: :destroy` on a scoped `has_many` association would only destroy the associated objects in that scope. Potentially leaving other associated objects outside that scope untouched.
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-659/+659
|
* modernizes hash syntax in activerecordXavier Noria2016-08-061-1/+1
|
* applies new string literal convention in activerecord/libXavier Noria2016-08-061-11/+11
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* [ci skip] Fix grammar in AR::AssociationsAlex Kitchens2016-07-181-13/+13
|
* Tiny document fixes [ci skip]Robin Dupret2016-05-301-1/+1
| | | | | | Add a missing capital letter and avoid using absolute links to the API because they may refer to out-dated documentation on the Edge site.
* Merge pull request #22240 from resource11/resource11-patch-1Arthur Nogueira Neves2016-05-291-4/+4
|\ | | | | Requesting documentation update
| * Issue 22240: adds link to list of instance methods [ci skip]Kathleen McMahon2016-03-181-4/+4
| | | | | | | | | | | | | | | | Update associations.rb Update associations.rb updates link to instance methods [ci skip]
* | Merge pull request #24672 from mrkjlchvz/mc-space-bumpRafael França2016-04-211-1/+1
|\ \ | | | | | | Minor space bump.
| * | Minor space bump.Mark2016-04-211-1/+1
| | |
* | | [ci skip] Update ActiveRecord associations documentation to avoid confusion ↵Tomasz Stachewicz2016-04-181-4/+8
|/ / | | | | | | with :validate option. Caused by #24532.
* | [ci skip] relations inside <tt> tagSourav Moitra2016-03-271-1/+1
| | | | | | | | | | | | s removed objects added
* | Merge pull request #23387 from mcfiredrill/clarify-touching-callbacksKasper Timm Hansen2016-01-311-0/+2
|\ \ | | | | | | clarify the touch true option does not trigger after_save/update [ci skip]
| * | clarify the touch true option does not trigger after_save/update [ci skip]Tony Miller2016-02-011-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | I've gotten tripped up more than a few times on this, thinking that using `belongs_to` with `touch: true` would trigger my after_save or after_update callbacks. The same text is in the documentation for the touch method itself, but I think its helpful to repeat it again here. It might save people some time.
* | | update doc for << method of has_many associationankit19102016-01-141-0/+1
| | |
* | | Expanding the documentation for collection=objects for has_many :through ↵Eric Krause2015-12-171-1/+2
| | | | | | | | | | | | [ci-skip]
* | | Use a real migration version number in docsMatthew Draper2015-12-151-1/+1
| | | | | | | | | | | | | | | Even though this means more things to change when we bump after a release, it's more important that our examples are directly copyable.
* | | Use a deliberately-invalid migration version in all doc examplesMatthew Draper2015-12-151-1/+1
| |/ |/| | | | | | | | | | | | | | | | | If we use a real version, at best that'll be an onerous update required for each release; at worst, it will encourage users to write new migrations against an older version than they're using. The other option would be to leave these bare, without any version specifier. But as that's just a variant spelling of "4.2", it would seem to raise the same concerns as above.
* | Fix Typo in EagerLoadPolymorphicError [ci skip]Alex Myers2015-10-271-1/+1
| |
* | Do not omit parentheses [ci skip]Ryuta Kamizono2015-10-251-11/+11
| |
* | [ci skip] readonly options has been removedIgnatius Reza2015-10-161-2/+0
|/
* applies new doc guidelines to Active Record.Yves Senn2015-10-141-95/+100
| | | | | | | | | | | | | | | | | | | The focus of this change is to make the API more accessible. References to method and classes should be linked to make it easy to navigate around. This patch makes exzessiv use of `rdoc-ref:` to provide more readable docs. This makes it possible to document `ActiveRecord::Base#save` even though the method is within a separate module `ActiveRecord::Persistence`. The goal here is to bring the API closer to the actual code that you would write. This commit only deals with Active Record. The other gems will be updated accordingly but in different commits. The pass through Active Record is not completely finished yet. A follow up commit will change the spots I haven't yet had the time to update. /cc @fxn
* document `EagerLoadPolymorphicError`. [ci skip]Yves Senn2015-10-131-2/+4
| | | | | | | | | This error is raised in certain situations when eager loading polymorphic associations. We even mention it in our docs. It should be included in our API. Conflicts: activerecord/lib/active_record/associations.rb
* Remove unnecessary display widthRyuta Kamizono2015-09-161-3/+3
| | | | | | | The **(11)** does not affect the storage size of the data type, which for an INT will always be 4 bytes. It affects the **display width**. http://www.tocker.ca/2015/07/02/proposal-to-deprecate-mysql-integer-display-width-and-zerofill.html
* Make ActiveRecordException descendants args optionalPavel Pravosud2015-09-071-35/+99
| | | | | | This change allows to instantiate all ActiveRecordError descendant execption classes without arguments, which might be useful in testing and is far less surprising than mandatory arguments.
* RDoc: fix wrong model name `:inverse_of` with `:belongs_to` [ci skip]Vladimir Rybas2015-07-301-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There's a typo in ActiveRecord associations RDocs. Wrong `Taggable` model name, instead of `Tagging` in example of using option `:inverse_of` with `:belongs_to` association. Commit where typo was introduced: https://github.com/rails/rails/commit/91fd6510563f84ee473bb217bc63ed598abe3f24#diff-39001423802a8470dba9c931e66e101eR11 First it appears in `activerecord/CHANGELOG` in example of `:inverse_of` usage: ```ruby class Post < ActiveRecord::Base has_many :taggings has_many :tags, :through => :taggings end class Tagging < ActiveRecord::Base belongs_to :post belongs_to :tag, :inverse_of => :tagging # :inverse_of must be set! end class Tag < ActiveRecord::Base has_many :taggings has_many :posts, :through => :taggings end post = Post.first tag = post.tags.build :name => "ruby" !> tag.save # will save a Taggable linking to the post ``` The last line should be ```ruby tag.save # will save a Tagging linking to the post ``` The same typo appears in `activerecord/lib/active_record/associations.rb`. The association name is given as `:inverse_of => :taggings`, but class name is `Taggable`. ```ruby # @post = Post.first # @tag = @post.tags.build :name => "ruby" # @tag.save # !> # The last line ought to save the through record (a <tt>Taggable</tt>). This will only work if the # <tt>:inverse_of</tt> is set: # !> # class Taggable < ActiveRecord::Base # belongs_to :post !> # belongs_to :tag, :inverse_of => :taggings # end ``` This PR fixes model name.
* Fix misleading errors for has_one through relationsMehmet Emin İNAÇ2015-07-221-2/+14
|
* [ci skip] Fix the API docs for Bi-directional associationsRoque Pinel2015-06-131-12/+7
| | | | | The examples now take in consideration when Active Record finds inverse associations automatically.
* add `extend` option on `has_and_belongs_to_many`.keepcosmos2015-05-261-1/+1
|
* deprecate `Relation#uniq` use `Relation#distinct` instead.Yves Senn2015-05-261-1/+0
| | | | | | | | | See #9683 for the reasons we switched to `distinct`. Here is the discussion that triggered the actual deprecation #20198. `uniq`, `uniq!` and `uniq_value` are still around. They will be removed in the next minor release after Rails 5.
* parent_reflection should store only a reflection objectAaron Patterson2015-05-191-2/+2
| | | | | we should ask the reflection for its name rather than storing the reflection name in two places (an array and a reflection object)
* [ci skip] Fix comment of `ActiveRecord::Associations#association_instance_get`yui-knk2015-05-111-1/+1
|
* change GeneratedFeatureMethods to GeneratedAssociationMethods in docsRob Looby2015-05-081-1/+1
| | | | the module name was changed in 8e814a0ac0768816974d2bfd68d33d931592751e
* Apply edits from @senny to close #19397 [ci skip]Zachary Scott2015-04-121-4/+1
|
* Change join model name constant to private constantMehmet Emin İNAÇ2015-04-071-3/+1
| | | | This will resolve the fixme message which is about making constant invisible.
* remove unnecessary path parameterskeepcosmos2015-03-101-16/+16
|
* Tiny documentation edits [ci skip]Robin Dupret2015-02-241-3/+1
|
* Require `belongs_to` by default.Josef Šimánek2015-02-211-1/+7
| | | | Deprecate `required` option in favor of `optional` for belongs_to.