Finne Jager wrote in post #971120:
> My routing:
>
> resources :incidents do
>     resource :timesheet do
>       resource :command_officer
>     end
> end
>
>
> My CommandOfficersController:
> def new
>     @command_officer = CommandOfficer.new
> ..
>
> Now if I want to add a Command Officer to an Incident's Timesheet, I go
> to:
> /incidents/41/timesheet/command_officer/new
>
> And I get this error:
>
> NoMethodError in Command_officers#new
> Showing C:/Rails/costrecovery/app/views/command_officers/_form.html.erb
> where line #1 raised:
>
> undefined method `command_officers_path' for
> #<#<Class:0x422f1c0>:0x422cb38>
>
> Extracted source (around line #1):
> 1: <%= form_for(@command_officer) do |f| %>
> 2:   <% if @command_officer.errors.any? %>
>
>
> Can anyone explain why I'm getting this error. I've been trying to find
> out for hours.

Since your resources are nested, you need to use the array syntax of 
form_for so that the proper route is generated.

Best,
-- 
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org

Sent from my iPhone

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to