I am trying to build a Rails app modded from Michael Hartl's Railstutorial. The code is located on GitHub.
I am using the following nested resources:
resources :users do
resources :scaffolds
end
But I am getting the following error:
ActionView::Template::Error (undefined method `scaffolds_path' for #<# <Class:0x007f87848019d0>:0x007f8782651948>):
4:
5: <div class="row">
6: <div class="span6 offset3">
7: <%= form_for(@scaffold) do |f| %>
8: <%= render 'shared/error_messages', object: f.object %>
9: <%= f.text_field :name, placeholder: "Scaffold name" %>
10: <%= f.text_area :description, placeholder: "Description" %>
app/views/scaffolds/new.html.erb:7:in `_app_views_scaffolds_new_html_erb___1119296061714080468_70109999031900'
I am puzzled why it is looking for scaffolds_path
and not user_scaffolds_path
?
The @scaffold
is created in the app/controller/scaffolds_controller.rb:
def new
@scaffold = current_user.scaffolds.build
end
Inspecting the @scaffold
object thus created shows:
'#<Scaffold id: nil, name: nil, description: nil, tax_id: nil, user_id: 36, created_at: nil, updated_at: nil>'
Dumping the methods of @scaffold
don't reveal any scaffolds_path
or user_scaffolds_path
methods which suggest additional problems?
The users model has_many :scaffolds
and the scaffold model belongs_to :user
.