Rails - Debugging Nested Routes

Posted by stringo0 on Stack Overflow See other posts from Stack Overflow or by stringo0
Published on 2010-06-09T22:43:25Z Indexed on 2010/06/09 23:12 UTC
Read the original article Hit count: 328

Hi,

I have 2 models, Assessments and Questions. Assessments have many questions.

In routes, I have:

map.resources :assessments, :has_many => :questions
map.root :assessments

I checked rake routes, it's as expected

On the form to create a new question, I get the following error:

undefined method `questions_path' for #<ActionView::Base:0x6d3cdb8>

If I take out the form, the view loads fine, so I think it's something with the code in this view - I'm getting the error on the form_for line:

<h1>New question</h1>

<% form_for [@assessment, @question] do |f| %>
  <%= f.error_messages %>

  <p>
    <%= f.label :content %><br />
    <%= f.text_field :content %>
  </p>
  <p>
    <%= f.submit 'Create' %>
  </p>
<% end %>

<%= link_to 'Cancel', assessment_path(@assessment) %>

Link to rake routes, if needed - http://pastebin.com/LxjfmXQw

Can anyone help me debug it? Thanks!

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about rails-models