Mix Resources and non Resource routes

Hello,

I have this routing right now:

map.resources :events do |event|
event.resources :invitations
event.resources :personalized_invitations
event.resources :questions
end

Now I want to add to the event resource other non resourceful routes.
In my case, this new route will be for my notification controller. Per
se notifications belongs to an event but are not resources so I don’t
want to use:

event.resources :notifications, :member=>[my notif actions here]

I would like the notification controller to behave as the default
rails routing but within the event scope. Something like this:
event.connect ‘:controller/:action/:id’

and then be able to have this kind of URL:
http://localhost:3000/events/notification/send/1

Is it possible to have such routing? How can I do this?

Thank you,
Julien.

Use named route:

map.notification ‘events/notification/send/:id’, :controller =>
‘ur_controller_name’, :action => ‘send’

The new way declaring your routes is:

map.resources :events , :has_many => [:invitations,
:personalized_invitations, :questions]

On Dec 20, 2007 10:30 AM, [email protected]
[email protected]
wrote:

and then be able to have this kind of URL:
http://localhost:3000/events/notification/send/1

Is it possible to have such routing? How can I do this?


http://www.rubyplus.org/
Free Ruby Screencasts

Hi,

Bala P. wrote:

Use named route:

map.notification ‘events/notification/send/:id’, :controller =>
‘ur_controller_name’, :action => ‘send’

The new way declaring your routes is:

map.resources :events , :has_many => [:invitations,
:personalized_invitations, :questions]

Sorry but, how can then you relate this map.resources :events with the
previous map.notification named routes created?
I mean, you are not mixing. You are just creating a named route with the
same first path as map.resources :events.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs