Forum: Ruby on Rails REST Routing issue

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ee0293412faca21e4ebf3326ed9d5f8c?d=identicon&s=25 Kad Kerforn (kadoudal)
on 2007-06-12 12:14
If I use http://0.0.0.0:3000/users/25/messages/new
I can create a new message ressource for user 25 that's OK....

I would like to be able to use such url :

http://0.0.0.0:3000/users/25/messages;send?to=5

in order to create a new message from user 25  for a specific receiver

how should write my route ?  I tried....

  map.resources :users do |users|
    users.resources :messages, :member => { :send => :get }
  end

but I got an error

no route found to match "/users/25/messages;send" with {:method=>:get}

thanks

kad
Ef3aa7f7e577ea8cd620462724ddf73b?d=identicon&s=25 Rob Biedenharn (Guest)
on 2007-06-26 01:28
(Received via mailing list)
On Jun 12, 2007, at 6:14 AM, Kad Kerforn wrote:
>
> kad
map.resources :users do |users|
     users.resources :messages, :new => { :send => :get }
   end

And then, of course, it's up to you to provide the :to => receiver.id
in your send_new_message_path() helper:  send_new_message_path(:to =>
receiver)
gives you:

   /users/25/messages/new;send?to=5


OR:
   map.resources :users do |users|
     users.resources :messages, :collection => { :send => :get }
   end

and then:  send_messages_path(:to => receiver)
gives you:

   /users/25/messages;send?to=5

-Rob

Rob Biedenharn    http://agileconsultingllc.com
Rob@AgileConsultingLLC.com
This topic is locked and can not be replied to.