Re: Routes: How would default routes be defined manually?

Mahmoud Said
Mon, 20 Dec 2010 09:44:48 -0000

it won''t work, it will be

add_new_priority GET    /priorities/new/add(.:format)
{:action=>"add",
:controller=>"priorities"}


however, the collection plural  form seems more logical to me, you are
adding a priority to priorities. so you are actually acting on priorities

On Mon, Dec 20, 2010 at 11:35 AM, Mahmoud Said
<eng.mahmoud.said-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:

> that''s interesting, apparently there is  3rd type other than
collection and
> member that is specific to the new.
>
>
> if u checked at actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:953
>
> you can how the default routes are added:
>
>             collection do
>               get  :index if parent_resource.actions.include?(:index)
>               post :create if parent_resource.actions.include?(:create)
>             end
>
>             new do
>               get :new
>             end if parent_resource.actions.include?(:new)
>
>             member do
>               get    :edit if parent_resource.actions.include?(:edit)
>               get    :show if parent_resource.actions.include?(:show)
>               put    :update if parent_resource.actions.include?(:update)
>               delete :destroy if parent_resource.actions.include?(:destroy)
>             end
>
> I''m not sure if you can use the "new" on your own. try
it and let me know
> how it goes :)
>
>
> On Mon, Dec 20, 2010 at 11:02 AM, bourne
<bourne7-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
>>
>>
>> On Monday, December 20, 2010 9:44:36 AM UTC+1, modsaid wrote
>>
>>> 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 ?
>>>
>>
>> Correct :)
>> (I know that this behaviour is fine for collections but I want to
>> understand why new is different and how to declare it to be identical)
>>
>> --
>> 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>> To unsubscribe from this group, send email to
>>
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
>> .
>> 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