Im trying to figure out what is it that you want. And if im not mistaken,
you want to add priority to behave the same as new_priority.
when you declare resource , rails automaticly assign 7 route respect to REST
the member method inside of the resource would apply to single instance of
the resource
so you get for examlpe
when you define
member do
get 'up'
get 'add'
end
you will get:
/prioriteis/*:id*/add
but when you define
collection do
get 'add'
end
you will get
/priorities/add
also if you dont specify aditional parameter, rails would create a route
name same as the get paramter
get 'add' would create add_priorities route and map it to priorites#add
*add* is referring to the get parameter and
*_priorities* referring to the resource
you could also specify a parameter to custom map your route. for example if
you want the add route is handled by *create* action on
*priorities*controller, then you could specify the method like this
get 'add' => 'priorities#create'
you could also custom the name of the path using :as parameter
get 'add' => 'priorities#create', :as => my_custom_add
Hope its help
On Sun, Dec 19, 2010 at 9:42 PM, bourne <[email protected]> wrote:
> No, I just failed on copy/paste and lost the end in the original post when
> removing the up-route :/
>
>
> resources :priorities do
> member do
> get 'up'
> get 'add'
> end
>
> collection do
>
> end
> end
>
> rake routes (complete)
> up_priority GET /priorities/:id/up(.:format)
> {:controller=>"priorities", :action=>"up"}
> add_priority GET /priorities/:id/add(.:format)
> {:controller=>"priorities", :action=>"add"}
> priorities GET /priorities(.:format)
> {:controller=>"priorities", :action=>"index"}
> priorities POST /priorities(.:format)
> {:controller=>"priorities", :action=>"create"}
> new_priority GET /priorities/new(.:format)
> {:controller=>"priorities", :action=>"new"}
> edit_priority GET /priorities/:id/edit(.:format)
> {:controller=>"priorities", :action=>"edit"}
> priority GET /priorities/:id(.:format)
> {:controller=>"priorities", :action=>"show"}
> priority PUT /priorities/:id(.:format)
> {:controller=>"priorities", :action=>"update"}
> priority DELETE /priorities/:id(.:format)
> {:controller=>"priorities", :action=>"destroy"}
> root /(.:format)
> {:controller=>"priorities", :action=>"index"}
--
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.