In my `ReviewsController`, I have two private methods called in `before_action`:

```
def find_course
  @course = Course.where(:id=>params[:course_id]).first
end

def find_professor
  @professor = Professor.where(:id=>params[:professor_id]).first
end

```

I'm querying `Course` through params, and for some reason, I get an `undefined method`id' for nil:NilClass` error in my create method:

```
def create
  @review = Review.new(review_params)
  @review.course_id = @course.id
  @review.professor_id = @professor.id
  @review.user_id = current_user.id

  if @review.save
    redirect_to course_path(@course)
  else
    render 'new'
  end
end

```

The create method is being called in a form partial as such:

```
<%= simple_form_for @review do |f| %>
  <%= f.input :rating %>
  <%= f.input :comment %>
  <%= f.button :submit %>
<% end %>

```

The form is displayed through a link in the course's show template:

```
<h2><%= @course.name %></h2>
<table class="table">
  <thead>
    <tr>
      <th scope="col">Professors</th>
      <th scope="col">Reviews</th>
    </tr>
  </thead>
  <tbody>
    <% @course.professors.each do |professor| %>
      <tr>
        <td><%= professor.name %></td>
        <td><%= link_to "Add Review", new_review_path(course_id: @course.id, professor_id: professor.id) %></td>
      </tr>
    <% end %>
  </tbody>
</table>

```

And `new_review_path` as defined in `routes.rb`:

```
resources :reviews, path_names: { new: 'course/:course_id/professor/:professor_id' }

```

For some odd reason, if I replace `@course = Course.where(:id=>params[:course_id]).first` with `@course = Course.find(7)` (7 being an id of an existing course), the create method works perfectly fine. How do I properly retrieve the Course and Professor records with the given params?