title: Ruby on Rails: undefined method `' for #<#<Class:>>
body: <p>I'm relatively new to rails and I've been struggling with this for a couple of days.  I'd be much appreciated if you can see where I've gone wrong.</p>
  
  <p>When I view the page in the web browser I get the following message:</p>
  
  <blockquote>
    <p>Showing C:/Users/Matt/Documents/GitHub/Outputer/app/views/studies/index.html.erb where line #8 raised:</p>
    
    <p>undefined method `studies_path' for #&lt;#:0x6b03808></p>
    
    <p>8: &lt;%= form_for @new_study do |f| %></p>
  </blockquote>
  
  <p><strong>studies_controller:</strong></p>
  
  <pre><code>def index
      @line = current_user.lines.find_by_id(params[:line_id])  
      @machine = @line.machines.find_by_id(params[:machine_id])  
      @studies = @machine.studies.paginate(page: params[:page], :per_page =&gt; 10)
      @new_study = @machine.studies.build
  end
  
  def create
      @study = current_user.lines.machines.study.build(params[:study])
      if @study.save
          flash[:success] = "Study created"  
      else
          flash[:error] = "Error : Invalid study description"  
      end
      redirect_to :back
  end
  </code></pre>
  
  <p><strong>index.html</strong></p>
  
  <pre><code>....
  &lt;section&gt;
  &lt;%= form_for @new_study do |f| %&gt;
      &lt;div class="field"&gt;
          &lt;%= f.text_field :description, placeholder: "New study description..." %&gt;
      &lt;/div&gt;
      &lt;%= f.submit "Create", class: "btn" %&gt;
  &lt;% end %&gt;
  &lt;/section&gt;
  ....
  </code></pre>
  
  <p><strong>Study Model</strong></p>
  
  <pre><code>....
  class Study &lt; ActiveRecord::Base
      belongs_to :machine
      belongs_to :line
      attr_accessible :avg_speed, :avg_uptime, :avg_yield, :description, :duration, :is_active, :start_time, :stop_time, :line_id
  
      validates ....
  
      has_many :events, dependent: :destroy
      ....
  end
  ....
  </code></pre>
  
  <p><strong>rake routes:</strong></p>
  
  <pre><code>....
  save_line_machine_study PUT    /lines/:line_id/machines/:machine_id/studies/:id/save(.:format) studies#save {:has_many=&gt;:machines}
  line_machine_studies    GET    /lines/:line_id/machines/:machine_id/studies(.:format)          studies#index {:has_many=&gt;:machines}
                          POST   /lines/:line_id/machines/:machine_id/studies(.:format)          studies#create {:has_many=&gt;:machines}
  new_line_machine_study  GET    /lines/:line_id/machines/:machine_id/studies/new(.:format)      studies#new {:has_many=&gt;:machines}
  edit_line_machine_study GET    /lines/:line_id/machines/:machine_id/studies/:id/edit(.:format) studies#edit {:has_many=&gt;:machines}
  line_machine_study      GET    /lines/:line_id/machines/:machine_id/studies/:id(.:format)      studies#show {:has_many=&gt;:machines}
                          PUT    /lines/:line_id/machines/:machine_id/studies/:id(.:format)      studies#update {:has_many=&gt;:machines}
                          DELETE /lines/:line_id/machines/:machine_id/studies/:id(.:format)      studies#destroy {:has_many=&gt;:machines}
  ....
  </code></pre>
  
  <p><strong>routes.rb</strong></p>
  
  <pre><code>resources :users
  resources :lines, :has_many =&gt; :machines,  only: [:index, :edit, :destroy, :show, :create] do
      resources :machines, only: [:new, :create, :edit, :update] do
          resources :studies 
      end
  end
  </code></pre>
  
  <p>If I remove the form the page works fine which would suggest its in the form.  I've tested the controller commands in the console and they all appear fine - I can create a new study object.</p>
  
  <p>Thanks in anticipation</p>