title: Parameter Error on Rails: `param is missing or the value is empty: exercise`
body: <p>I am trying to access the <code>exercises#index</code> page for my app, coming from the <code>workouts#show</code> page.  The structure of these models is:</p>
  
  <pre><code>  resources :workouts do
      resources :exercises do
        resources :reports, shallow: true
      end
    end
  </code></pre>
  
  <p>I am getting <code>param is missing or the value is empty: exercise</code> called on the first line of my parameters.  My entire (UPDATED) <code>exercises_controller</code> is:</p>
  
  <pre><code>class ExercisesController &lt; ApplicationController
    before_action :authenticate_user!
  
    def index
        @workout = Workout.friendly.find(params[:id])
        @exercise = Exercise.new
        @exercises = Exercise.all
    end
  
    def new
      @workout = Workout.friendly.find(params[:id])
      @exercise = Exercise.new
    end
  
    def create
      @workout = Workout.friendly.find(params[:workout_id])
      exercise = @workout.exercises.build(exercise_params)
      exercise.user = current_user
  
      if exercise.save
        flash[:notice] = "Results saved successfully."
        redirect_to [@workout]
      else
        flash[:alert] = "Results failed to save."
        redirect_to [@workout]
      end
    end
  
    def edit
      @workout = Workout.friendly.find(params[:id])
      exercise = Exercise.find(params[:id])
      exercise.user = current_user
    end
  
    def destroy
      @workout = Workout.friendly.find(params[:workout_id])
      exercise = @workout.exercises.find(params[:id])
  
      if exercise.destroy
        flash[:notice] = "Exercise was deleted successfully."
        redirect_to [@workout]
      else
        flash[:alert] = "Exercise couldn't be deleted. Try again."
        redirect_to [@workout]
      end
    end
  
    private
  
    def exercise_params
        params.require(:exercise).permit(:name, :needs_seconds, :needs_weight, :needs_reps, :workout_id)
    end
  
    def authorize_user
      exercise = Exercise.find(params[:id])
      unless current_user == current_user.admin?
        flash[:alert] = "You do not have permission to create or delete an exercise."
        redirect_to [exercise.workout]
      end
    end
  end
  </code></pre>
  
  <p>The only thing that's all that complicated in my structure is the user will be able to create, edit, and delete <code>exercises</code> all from the <code>exercises#index</code> page.  The link I'm using to get to this <code>exercises#index</code> page is coming from the <code>workouts#show</code> page:</p>
  
  <pre><code>&lt;%= link_to 'Add/Edit Exercises', workout_exercises_path(@workout, @exercise), method: :index %&gt;
  </code></pre>
  
  <p>Finally, if it's needed here are the applicable routes:</p>
  
  <pre><code>   workout_exercise_reports GET    /workouts/:workout_id/exercises/:exercise_id/reports(.:format)     reports#index
                              POST   /workouts/:workout_id/exercises/:exercise_id/reports(.:format)     reports#create
  new_workout_exercise_report GET    /workouts/:workout_id/exercises/:exercise_id/reports/new(.:format) reports#new
                  edit_report GET    /reports/:id/edit(.:format)                                        reports#edit
                       report GET    /reports/:id(.:format)                                             reports#show
                              PATCH  /reports/:id(.:format)                                             reports#update
                              PUT    /reports/:id(.:format)                                             reports#update
                              DELETE /reports/:id(.:format)                                             reports#destroy
            workout_exercises GET    /workouts/:workout_id/exercises(.:format)                          exercises#index
                              POST   /workouts/:workout_id/exercises(.:format)                          exercises#create
         new_workout_exercise GET    /workouts/:workout_id/exercises/new(.:format)                      exercises#new
        edit_workout_exercise GET    /workouts/:workout_id/exercises/:id/edit(.:format)                 exercises#edit
             workout_exercise GET    /workouts/:workout_id/exercises/:id(.:format)                      exercises#show
                              PATCH  /workouts/:workout_id/exercises/:id(.:format)                      exercises#update
                              PUT    /workouts/:workout_id/exercises/:id(.:format)                      exercises#update
                              DELETE /workouts/:workout_id/exercises/:id(.:format)                      exercises#destroy
                     workouts GET    /workouts(.:format)                                                workouts#index
                              POST   /workouts(.:format)                                                workouts#create
                  new_workout GET    /workouts/new(.:format)                                            workouts#new
                 edit_workout GET    /workouts/:id/edit(.:format)                                       workouts#edit
                      workout GET    /workouts/:id(.:format)                                            workouts#show
                              PATCH  /workouts/:id(.:format)                                            workouts#update
                              PUT    /workouts/:id(.:format)                                            workouts#update
                              DELETE /workouts/:id(.:format)                                            workouts#destroy
  </code></pre>
  
  <p>Can anyone see what's wrong with my parameters that is generating this error</p>
  
  <p>ADDITIONAL INFORMATION:</p>
  
  <p>Here's my <code>exercises/index.html.erb</code>:</p>
  
  <pre><code>&lt;div class="container col-sm-10 col-sm-push-1" style="margin-top: 100px"&gt;
    &lt;div class="opaque-card md-well well"&gt;
      &lt;h1&gt;Current Exercises:&lt;/h1&gt;
        &lt;% @exercises.each do |exercise| %&gt;
          &lt;p&gt;&lt;%= exercise.name %&gt; (&lt;%= link_to "Delete #{exercise.name}", exercise_path(exercise), method: :delete, data: { confirm: 'Are you sure?' } %&gt;)&lt;/p&gt;
        &lt;% end %&gt;
      &lt;h1&gt;Add New Exercises:&lt;/h1&gt;
        &lt;%= render 'exercises/form' %&gt;
    &lt;/div&gt; &lt;!-- opaque card --&gt;
  &lt;/div&gt; &lt;!-- container --&gt;
  </code></pre>
  
  <p>And here's the <code>exercises/form</code> it renders:</p>
  
  <pre><code>&lt;div class="row"&gt;
    &lt;div class="col-xs-10 col-xs-push-1"&gt;
      &lt;%= form_for @exercise do |f| %&gt;
        &lt;%= f.hidden_field :workout_id, value: @workout.id %&gt;
        &lt;div class="form-group"&gt;
          &lt;%= f.label :name, class: 'sr-only' %&gt;
          &lt;%= f.text_field :name, class: 'form-control', placeholder: "Enter exercise name" %&gt;
        &lt;/div&gt;
  
        &lt;div class="form-group col-xs-4"&gt;
          &lt;p&gt;&lt;%= f.label :needs_seconds, class: 'sr-only' %&gt;
          &lt;%= f.check_box :needs_seconds, class: 'check_box' %&gt; Report seconds?&lt;/p&gt;
        &lt;/div&gt;
  
        &lt;div class="form-group col-xs-4"&gt;
          &lt;p&gt;&lt;%= f.label :needs_reps, class: 'sr-only' %&gt;
          &lt;%= f.check_box :needs_reps, class: 'check_box' %&gt; Report reps?&lt;/p&gt;
        &lt;/div&gt;
  
        &lt;div class="form-group col-xs-4"&gt;
          &lt;p&gt;&lt;%= f.label :needs_weight, class: 'sr-only' %&gt;
          &lt;%= f.check_box :needs_weight, class: 'check_box' %&gt; Report weight?&lt;/p&gt;
        &lt;/div&gt;
  
        &lt;div class="text-center"&gt;&lt;%= f.submit "Create Exercise", class: 'btn btn-primary' %&gt;&lt;/div&gt;
      &lt;% end %&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>And here's the server log before I hit the error:</p>
  
  <pre><code>Started POST "/workouts/d/exercises" for ::1 at 2016-06-03 08:18:26 -0700
  Processing by ExercisesController#create as HTML
    Parameters: {"authenticity_token"=&gt;"lygWA3+umw/oGYb/m/W3Oi+M8j/E6+bovZL8zNjO6oZglGkQQkR+FlPNh4CzmQjf4ZE9XffdDLoe4FJ3rPpZ0Q==", "workout_id"=&gt;"d"}
    User Load (0.1ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = ?  ORDER BY "users"."id" ASC LIMIT 1  [["id", 1]]
    Workout Load (0.1ms)  SELECT  "workouts".* FROM "workouts" WHERE "workouts"."slug" = ?  ORDER BY "workouts"."id" ASC LIMIT 1  [["slug", "d"]]
  Completed 400 Bad Request in 3ms (ActiveRecord: 0.2ms)
  </code></pre>