Reputation: 1113
I am a Rails noob and not sure what is causing the Undefined method error. Here's my code:
namespace :dashboard do
resources :subjects
end
<%= form_for(@subject) do |f| %>
<%= f.label :name %>
<%= f.text_field :name %>
<%= f.submit "Submit" %>
<% end %>
module Dashboard
class SubjectsController < ApplicationController
def new
@subject = Subject.new
end
end
end
When I load /dashboard/subjects/new in the browser, I get the following error on the form_for(@subject) line
undefined method `subjects_path' for #<#<Class:0x007f951e0f2b38>:0x007f951e0f18f0>
What am I doing wrong here?
Upvotes: 0
Views: 64
Reputation: 8065
This should work since you are having namespaced resource
<%= form_for([:dashboard, @subject]) do |f| %>
Upvotes: 4