Finne Jager wrote in post #968340:
>> Instead of asking us, look at your rake routes output again!  That's why
>> it's there.
>
> Thanks, I just did and realized what I had to change.
>
> With these nested resources in place, do I still have to set @timesheet
> in TimesheetsController#show?

Of course.  Changing routes.rb only changes the routing, nothing else.

You may want to use a plugin such as make_resourceful to abstract some 
of this.

>
> This is what I had before:
> -------------------------
> def show
>  @timesheet = current_user.timesheets.find(params[:id])
> -------------------------

Why the current_user part?  Just Timesheet.find(params[:id]) should do 
the trick -- after all, the ID is unique.

>
> The reason I'm asking is because in timehsheets/show.html.erb I have:
> -------------------------
> <p>
>   <b>Date:</b>
>   <%= timesheet.date %>
> </p>
> -------------------------
> which is not working (undefined local variable or method `timesheet'). I
> just want to retrieve the value for 'date' in the database timesheet
> table..

Of course that's not working.  You haven't defined timesheet anywhere.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@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-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