On 14 December 2010 17:39, Finne Jager <li...@ruby-forum.com> wrote:
>> Why the current_user part?  Just Timesheet.find(params[:id]) should do
>> the trick -- after all, the ID is unique.
>
> I read in Beginning Rails 3 that current_user makes sure that the logged
> in user can not see other people's incidents/timesheets. I have the same
> thing in the IncidentsController:
> ------------------------------
> def index
>   �...@incidents = current_user.incidents.all
> -------------------------------
>
>
>> Of course that's not working.  You haven't defined timesheet anywhere.
>
> @timesheet = Timesheet.find(params[:id])
>
> Seems to be not working... Does it even need to find by ID if I'm
> already using the incident_timesheet_path(incident) link?

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.

Colin

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