From 4ec818d28c3984ec9d27c362fc8ff48af9335cde Mon Sep 17 00:00:00 2001 From: Vladimir Rybas Date: Thu, 30 Jul 2015 22:04:28 +0700 Subject: RDoc: fix wrong model name `:inverse_of` with `:belongs_to` [ci skip] 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 Taggable). This will only work if the # :inverse_of is set: # !> # class Taggable < ActiveRecord::Base # belongs_to :post !> # belongs_to :tag, :inverse_of => :taggings # end ``` This PR fixes model name. --- activerecord/lib/active_record/associations.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index a830b0e0e4..19ef37e228 100644 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -619,10 +619,10 @@ module ActiveRecord # @tag = @post.tags.build name: "ruby" # @tag.save # - # The last line ought to save the through record (a Taggable). This will only work if the + # The last line ought to save the through record (a Tagging). This will only work if the # :inverse_of is set: # - # class Taggable < ActiveRecord::Base + # class Tagging < ActiveRecord::Base # belongs_to :post # belongs_to :tag, inverse_of: :taggings # end @@ -643,7 +643,7 @@ module ActiveRecord # You can turn off the automatic detection of inverse associations by setting # the :inverse_of option to false like so: # - # class Taggable < ActiveRecord::Base + # class Tagging < ActiveRecord::Base # belongs_to :tag, inverse_of: false # end # -- cgit v1.2.3