Ruby on Rails Wednesday, December 29, 2010

Finne Jager wrote in post #971310:
> I'm having another issue.
> This is my create method for a Command Officer:
>
> def create
> @timesheet = Incident.find(params[:incident_id]).timesheet
>
> respond_to do |format|
> if @timesheet.create_command_officer(params[:command_officer])
>
>
> This is working fine. But when I use the same code in
> FireFighter#create:
> if @timesheet.create_fire_fighter(params[:fire_fighter])
>
> I get this error:
> NoMethodError in Fire fightersController#create
> undefined method `create_fire_fighter' for
> "#<Timesheet:0x3f8b938>":Timesheet
>
> As far as I know everything is set up identical to Command Officer

Obviously it isn't.

> and I
> don't know why the create_fire_fighter doesn't work, while it does work
> for Command Officer?

You forgot to set up the associations on Timesheet properly. What
associations does Timesheet currently have?

Best,
-- 
Marnen Laibow-Koser
http://www.marnen.org
marnen@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-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment