I'm having some issues understanding how to nest 3 models. I'm trying to, at the deepest point of the relations, add a `Video` to the `WorkoutSteps` (not creating a new video but select an existing one from a dropdown)

Models:

`Workout`
`WorkoutSet`
`WorkoutStep` -> just an array of `Video`
`Video`

*Relationships*
Workout:
`has_and_belongs_to_many :workout_sets, :join_table => :workout_sessions, dependent: :destroy`

WorkoutSet
`has_and_belongs_to_many :workout_steps, :join_table => :sets_steps, dependent: :destroy`

WorkoutStep
`has_and_belongs_to_many :workout_sets, :join_table => :sets_steps`

And the following in the views:

\_form.html.haml

```
= simple_form_for(@workout, url: admin_workouts_path(@workout)) do |f|
  = f.input :title
  %h3 Sets
  .sets.some{ :style => "margin-left: 25px" }
    = f.simple_fields_for :workout_sets do |set|
      = render 'workout_set_fields', f: set
    .links
      = link_to_add_association 'add set', f, :workout_sets
  = f.submit

```

\_workout\_set\_fields

```
= f.label :title
= f.text_field :title
%br
%br
  #sets.some{ :style => "margin-left: 25px" }
    = f.simple_fields_for :workout_steps do |step|
      = render 'workout_step_fields', f: step
    .links
      = link_to_add_association 'add step', f, :workout_steps

```

\_workout\_step\_fields

```
= f.association :main_videos, include_hidden: false

```

workouts\_controller.rb

```
def workout_params
    params.require(:workout).permit(:title, :pro, :workout_step_id, workout_sets_attributes: [ :id, :_destroy, :title, workout_steps_attributes: [ main_video_ids: [:id] ] ])
end

```

Checking the params:

![screen shot 2016-04-08 at 8 34 51 pm](https://cloud.githubusercontent.com/assets/6905948/14393857/68fb106e-fdc9-11e5-994e-011d32bb52b2.png)