Adding a view (newby question)

How do you add an extra view?
I have “new, edit, show, etc.”.
I’m having trouble using RESTful paths.
“new_viewname_path” works for linking to the “new” view but if I try
something like “myview_viewname_path” I get an error: “undefined local
variable or method `myview_viewname_path’”
Can anybody help?

Jason Cheung wrote:

How do you add an extra view?
I have “new, edit, show, etc.”.
I’m having trouble using RESTful paths.
“new_viewname_path” works for linking to the “new” view but if I try
something like “myview_viewname_path” I get an error: “undefined local
variable or method `myview_viewname_path’”
Can anybody help?

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:

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.

Max W. 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)”.

Jason Cheung wrote:

Max W. 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.