Ruby on Rails Tuesday, December 14, 2010

> All the link does is build a URL for you with appropriate params. In
> the controller action you then have to do things with the params.
> Have a look in log/development.log and you will see what params are
> being passed. Also I suggest having a look at the Rails Guide on
> debugging. You can then use ruby-debug to break into your code before
> the find call you have shown and inspect params to see what is there
> and work out why the find is not working. You can also experiment
> then calling find from the console to see what works.

I didn't think of checking the log, very useful tip!
I need to use the incident_id that's being passed to find the timesheet.

I tried:
@timesheet = Incident.find(params[:id]).timesheet

"Couldn't find Incident without an ID".

I checked by hardcoding it:
@timesheet = Incident.find(1).timesheet

That did work, so it must be params[:id] that's not working. The log
says that incident_id is being passed as a param though.

Started GET "/incidents/1/timesheet" for 127.0.0.1 at 2010-12-14
12:33:48 -0500
Processing by TimesheetsController#show as HTML
Parameters: {"incident_id"=>"1"}

--
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