Given that you already know what we mentioned. and the correct usage is
resources :priorities do
collection do
get 'add'
end
end
I think what confuses you is: "why is it add_priorities_path and not
add_priority_path like the new_priority_path" (in a singular form)?
is that right ?
On Mon, Dec 20, 2010 at 10:40 AM, Mahmoud Said
<[email protected]>wrote:
> Bourne,
>
> In your example, *add* is like *new. *It should not be a member action, it
> is a collection one.
>
> I think what you are asking for is a bit more elaboration of the default
> REST routes.
>
> When you do:
>
> resources :priorities
>
> This will generate the 7 default routes. which are two types:
>
> 1. Member (you are operating on a specific instance of the priorities).
> and those are: Show, Edit, Update, Destroy
> 2. Collection, Where you operate on prorities in general, but not an
> existing one of them. which is :index, :new, :create
>
>
> for member based actions, the paths generated in a singular form and
> expects the ID to be passed. so
>
> add_priority_path # wrong, you have not provided an id or an instance of
> Priority
> add_priority_path(object) # should work, but this is not what u want.
>
> new_priority_path is actually a collection. the route will be
> /priorities/new
>
>
>
>
>
>
> On Mon, Dec 20, 2010 at 9:50 AM, bourne <[email protected]> wrote:
>
>> Thank you! Your post is really helpful.
>>
>> As mentioned above, I just want to understand how I would declare the 7
>> REST routes if they would not have been declared for me, e.g. new1 (add in
>> my example), edit1, ...
>> If I declare add as a collection route, this statement throws an error
>> <%= link_to 'Add Priority', add_*priority*_path %> (taken from
>> originally created code : <%= link_to 'New Priority', new_priority_path %>)
>>
>> <%= link_to 'Add Priority', add_*priorities*_path %> works as expected.
>>
>> My original question was: what is my definition missing compared to the
>> original new?
>>
>>
>> Second, I find this very interesting: get 'add' => 'priorities#create',
>> :as => my_custom_add
>> In this form I get an error, the same with :my_custom_add.
>>
>> --
>> 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]<rubyonrails-talk%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/rubyonrails-talk?hl=en.
>>
>
>
>
> --
> Mahmoud Said
> Software Engineer - eSpace
> blog.modsaid.com
>
>
>
>
--
Mahmoud Said
Software Engineer - eSpace
blog.modsaid.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.