Error in form for a model which belongs_to another

Hi everyone, be forewarned that I’m new to ruby and rails.

I’ve got two models Course and Lesson. Course has_many :lessons and
belongs_to :course. Currently the models themselves just have
attr_accessible with the :name and :description fields.

When I try to load the form to create a new lesson (url is
I get an error which says: undefined method `lessons_path’ and it points
line 1 of the form partial for making new lessons. I’ve tried searching
the net for a couple days now and have tried several different things,
I can’t figure it out.

Here’s the code:
lessons_controller.rb (relevant methods only)

  • def new @course = Course.find(params[:course_id]) @lesson = end def create @course =
    Course.find(params[:course_id]) @lesson =
    @course.lessons.create(params[:lesson]) if redirect_to
    course_path(@course), :notice => “Successfully created lesson.” else
    :action => ‘new’, :error => “Something went wrong.” end end

*<%= form_for(@lesson) do |f| %> <%= f.error_messages %>

<%= f.label
:name %>
<%= f.text_field :name %>

f.label :description %>
<%= f.text_area :description %>

<%= f.submit "Submit" %>
<% end %>* * * *routes.rb* * resources :courses do member do get 'detail' end resources :lessons end *