Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RDoc: fix wrong model name :inverse_of with :belongs_to [ci skip] #21074

Merged

Conversation

vrybas
Copy link
Contributor

@vrybas vrybas commented Jul 30, 2015

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:
91fd651#diff-39001423802a8470dba9c931e66e101eR11

First it appears in activerecord/CHANGELOG in example of :inverse_of
usage:

    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

    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.

    #   @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.

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:
rails@91fd651#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.
@zzak zzak added the docs label Aug 1, 2015
robin850 added a commit that referenced this pull request Aug 25, 2015
…e-of-class-name

RDoc: fix wrong model name `:inverse_of` with `:belongs_to` [ci skip]
@robin850 robin850 merged commit a70e6f1 into rails:master Aug 25, 2015
@robin850
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants