Finne Jager wrote in post #971314:
>> You forgot to set up the associations on Timesheet properly. What
>> associations does Timesheet currently have?
>
> class Timesheet < ActiveRecord::Base
> belongs_to :incident
>
> has_one :command_officer
> has_one :fire_chief
> has_many :fire_fighters
Still using the data model I advised you against, I see...
...but in any case, I think you want @timesheet.fire_fighters.create,
not @timesheet.create_fire_fighter , which doesn't exist on has_many.
>
>
> class FireFighter < ActiveRecord::Base
> belongs_to :timesheet
>
>
> I tested it with the console, Tiemsheet.last.fire_fighters returns an
> empty array []
You do know that Timesheet.last will return an arbitrary timesheet, and
that you can't predict which one it returns, right?
Best,
--
Marnen Laibow-Koser
http://www.marnen.org
marnen@marnen.org
--
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