# Relations

One of the most amazing things about Ruby on Rails is how easy it is to create relations (Active Record associations (opens new window)) between models. We try to keep the same simple approach in Avo too.

At the moment, Avo supports four relation types.

# Belongs to

belongs_to :user

When you add a BelongsTo relation to a model, you will see three different field types.

On the Index view, you'll see a column with the @title value of the associated model.

Belongs to index

On the Show view, you'll see a link to the associated model.

Belongs to show

On the Edit and Create views, you'll see a drop-down element with the available records. Here you may change the associated model.

Belongs to edit

# Has One

The HasOne relation works similarly to BelongsTo.

has_one :admin

# Has Many

The HasMany field is visible only on the Show page. Below the regular fields panel, you will see a new panel with the model's associated records.

has_many :projects
Has many table

Here you may attach more records by clicking the "Attach" button.

Has many attach

In a similar fashion, you may detach a model using the detach button.

Has many detach

# Has And Belongs To Many

The HasAndBelongsToMany relation works similarly to HasMany.

has_and_belongs_to_many :users