Jason Cheung wrote:
> Max Williams wrote:
>> the 'new' path and the 'edit' path are the only ones that actually have 
>> the name of the action in them.  The rest are determined based on 
>> whether you refer to the singular or plural version of the resource (eg 
>> comments vs comment) and the type of the request.  I found this 
>> cheatsheet very handy when i started using REST: 
>> http://topfunky.com/clients/peepcode/REST-cheatsheet.pdf
>> 
>> The cheatsheet shows you how to add custom actions as well: basically 
>> you put the action in your controller and moddify the entry for that 
>> resource in your routes.rb.  The views themselves are not the problem 
>> you were encountering:  if the action is run successfully it will drop 
>> through to the view automatically.  To put it another way, a path points 
>> to a particular action in a particular controller, rather than to a 
>> view.
> 
> Thanks a million max. That cheat sheet was great. I got it linking to 
> the right view.
> I used "theview_plural_path(idNum)".

BTW the reason that you can pass an object to the path, rather than it's 
id, is that the method 'to_param' will be called on the object, and by 
default this returns the id.  So, it's best to always pass the object to 
the path: later on, if you want the url to show the name, for example, 
rather than the id, you just override to_param for that model and it 
magically works.  If you're always passing ids through then you would 
have to hunt out all the times you call that path and change them.
-- 
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to