Skip to content

Commit

Permalink
Add Associations section to Active Record basics guide [ci-skip]
Browse files Browse the repository at this point in the history
The other Active Record guides are mentioned in the Basics guide as
well, so it makes sense to also shortly mention the associations and
where to find out more about them.
  • Loading branch information
p8 committed Jan 6, 2023
1 parent 10c2b3a commit 32823ce
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions guides/source/active_record_basics.md
Expand Up @@ -395,3 +395,23 @@ PostgreSQL, Oracle, and others.

You can learn more about migrations in the [Active Record Migrations
guide](active_record_migrations.html).

Associations
------------

Active Record associations allow you to define relationships between models.
Associations can be used to describe one-to-one, one-to-many, and many-to-many
relationships. For example, a relationship like “Author has many Books” can be
defined as follows:

```ruby
class Author < ApplicationRecord
has_many :books
end
```

The Author class now has methods to add and remove books to an author, and much
more.

You can learn more about associations in the [Active Record Associations
guide](associations_basics.html).

0 comments on commit 32823ce

Please sign in to comment.