Hello, I''m now playing with REST and Rails (with Rails 1.2.1). I have the following routes in my route.rb : map.with_options :path_prefix => "/admin", :name_prefix => "admin_" do |m| m.resources :requests, :controller => "admin/requests" end This give me a RESTful /admin/requests controller. In my application, a Request has many Histories. How can I add the correct route to have something like that : /admin/requests/24/histories. Without the /admin, it would simply look like this : map.resources :requests do |request| request.resources :histories end But with the /admin, everything becomes to be confused for me. Any help would be greatly appreciated. Thanks in advance, Thomas. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
try this: map.with_options :path_prefix => "/admin", :name_prefix => "admin_" do |m| m.resources :requests, :controller => "admin/requests" do |req| req.resources :histories end end ed On 2/2/07, Thomas Balthazar <thomas.tmp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello, > > I''m now playing with REST and Rails (with Rails 1.2.1). > > I have the following routes in my route.rb : > > map.with_options :path_prefix => "/admin", :name_prefix => "admin_" do |m| > m.resources :requests, :controller => "admin/requests" > end > > This give me a RESTful /admin/requests controller. > > In my application, a Request has many Histories. > How can I add the correct route to have something like that : > /admin/requests/24/histories. > > Without the /admin, it would simply look like this : > map.resources :requests do |request| > request.resources :histories > end > > But with the /admin, everything becomes to be confused for me. > Any help would be greatly appreciated. > > Thanks in advance, > Thomas. > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hello Ed, Thanks for your answer. When I do this : map.with_options :path_prefix => "/admin", :name_prefix => "admin_" do |m| m.resources :requests, :controller => "admin/requests" do |request| request.resources :histories end end And in my view I do this : <%= admin_histories_url %> I get this error : undefined local variable or method `admin_histories_url'' So I''ve changed to that : map.with_options :path_prefix => "/admin", :name_prefix => "admin_" do |m| m.resources :histories, :controller => "admin/histories" m.resources :requests, :controller => "admin/requests" do |request| request.resources :histories end end And now : <%= admin_histories_url %> give me this : http://0.0.0.0:3000/admin/histories If I try this in my view : <%= admin_histories_url(@request) %> I get this error : You have a nil object when you didn''t expect it! The error occurred while evaluating nil.to_sym So I don''t think it solves the problem. Any idea? Thanks, Thomas. On 2/2/07, Ed Hickey <bassnode-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > try this: > > map.with_options :path_prefix => "/admin", :name_prefix => "admin_" do |m| > m.resources :requests, :controller => "admin/requests" do |req| > req.resources :histories > end > end > > > ed > > > On 2/2/07, Thomas Balthazar <thomas.tmp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hello, > > > > I''m now playing with REST and Rails (with Rails 1.2.1). > > > > I have the following routes in my route.rb : > > > > map.with_options :path_prefix => "/admin", :name_prefix => "admin_" do > |m| > > m.resources :requests, :controller => "admin/requests" > > end > > > > This give me a RESTful /admin/requests controller. > > > > In my application, a Request has many Histories. > > How can I add the correct route to have something like that : > > /admin/requests/24/histories. > > > > Without the /admin, it would simply look like this : > > map.resources :requests do |request| > > request.resources :histories > > end > > > > But with the /admin, everything becomes to be confused for me. > > Any help would be greatly appreciated. > > > > Thanks in advance, > > Thomas. > > > > > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
It seems to work with this in my route.rb : map.with_options :path_prefix => "/admin", :name_prefix => "admin_" do |m| m.resources :requests, :controller => "admin/requests" do |request| request.resources :histories, :path_prefix => "/admin/requests/:request_id", :name_prefix => "admin_" end end If I try that in my view : <%= admin_histories_url(@request) %><br /> I now get this : http://0.0.0.0:3000/admin/requests/24/histories If anybody wants to comment this solution, he is more than welcome. I''m not sure to do the right thing here. Thanks, Thomas. On 2/2/07, Thomas Balthazar <thomas.tmp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hello Ed, > Thanks for your answer. > > When I do this : > map.with_options :path_prefix => "/admin", :name_prefix => "admin_" do > |m| > m.resources :requests, :controller => "admin/requests" do |request| > request.resources :histories > end > end > > And in my view I do this : > <%= admin_histories_url %> > > I get this error : > undefined local variable or method `admin_histories_url'' > > So I''ve changed to that : > map.with_options :path_prefix => "/admin", :name_prefix => "admin_" do > |m| > m.resources :histories, :controller => "admin/histories" > m.resources :requests, :controller => "admin/requests" do |request| > request.resources :histories > end > end > > And now : <%= admin_histories_url %> give me this : > http://0.0.0.0:3000/admin/histories > > If I try this in my view : > <%= admin_histories_url(@request) %> > > I get this error : > You have a nil object when you didn''t expect it! > The error occurred while evaluating nil.to_sym > > So I don''t think it solves the problem. > Any idea? > Thanks, > Thomas. > > On 2/2/07, Ed Hickey < bassnode-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > try this: > > > > map.with_options :path_prefix => "/admin", :name_prefix => "admin_" do > > |m| > > m.resources :requests, :controller => "admin/requests" do |req| > > req.resources :histories > > end > > end > > > > > > ed > > > > > > On 2/2/07, Thomas Balthazar < thomas.tmp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hello, > > > > > > I''m now playing with REST and Rails (with Rails 1.2.1). > > > > > > I have the following routes in my route.rb : > > > > > > map.with_options :path_prefix => "/admin", :name_prefix => "admin_" do > > |m| > > > m.resources :requests, :controller => "admin/requests" > > > end > > > > > > This give me a RESTful /admin/requests controller. > > > > > > In my application, a Request has many Histories. > > > How can I add the correct route to have something like that : > > > /admin/requests/24/histories. > > > > > > Without the /admin, it would simply look like this : > > > map.resources :requests do |request| > > > request.resources :histories > > > end > > > > > > But with the /admin, everything becomes to be confused for me. > > > Any help would be greatly appreciated. > > > > > > Thanks in advance, > > > Thomas. > > > > > > > > > > > > > > > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
so if you do this: <%= admin_histories_url(@request) %> you should get something like: "/admin/requests/1/histories" if you do this: <%= admin_histories_url(@request, @history) %> you should get something like: "/admin/requests/1/histories/2" You have achieved what you requested in your original email, no? ed On 2/2/07, Thomas Balthazar <thomas.tmp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> It seems to work with this in my route.rb : > map.with_options :path_prefix => "/admin", :name_prefix => "admin_" do |m| > m.resources :requests, :controller => "admin/requests" do |request| > request.resources :histories, :path_prefix => > "/admin/requests/:request_id", :name_prefix => "admin_" > end > end > > If I try that in my view : > <%= admin_histories_url(@request) %><br /> > > I now get this : > http://0.0.0.0:3000/admin/requests/24/histories > > If anybody wants to comment this solution, he is more than welcome. > I''m not sure to do the right thing here. > > Thanks, > Thomas. > > > > > On 2/2/07, Thomas Balthazar <thomas.tmp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hello Ed, > > Thanks for your answer. > > > > When I do this : > > map.with_options :path_prefix => "/admin", :name_prefix => "admin_" do > |m| > > m.resources :requests, :controller => "admin/requests" do |request| > > request.resources :histories > > end > > end > > > > And in my view I do this : > > <%= admin_histories_url %> > > > > I get this error : > > undefined local variable or method `admin_histories_url'' > > > > So I''ve changed to that : > > map.with_options :path_prefix => "/admin", :name_prefix => "admin_" do > |m| > > m.resources :histories, :controller => "admin/histories" > > m.resources :requests, :controller => "admin/requests" do |request| > > request.resources :histories > > end > > end > > > > And now : <%= admin_histories_url %> give me this : > http://0.0.0.0:3000/admin/histories > > > > If I try this in my view : > > <%= admin_histories_url(@request) %> > > > > I get this error : > > You have a nil object when you didn''t expect it! > > The error occurred while evaluating nil.to_sym > > > > So I don''t think it solves the problem. > > Any idea? > > Thanks, > > Thomas. > > > > > > > > On 2/2/07, Ed Hickey < bassnode-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > try this: > > > > > > map.with_options :path_prefix => "/admin", :name_prefix => "admin_" do > |m| > > > m.resources :requests, :controller => "admin/requests" do |req| > > > req.resources :histories > > > end > > > end > > > > > > > > > ed > > > > > > > > > On 2/2/07, Thomas Balthazar < thomas.tmp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hello, > > > > > > > > I''m now playing with REST and Rails (with Rails 1.2.1). > > > > > > > > I have the following routes in my route.rb : > > > > > > > > map.with_options :path_prefix => "/admin", :name_prefix => "admin_" do > |m| > > > > m.resources :requests, :controller => "admin/requests" > > > > end > > > > > > > > This give me a RESTful /admin/requests controller. > > > > > > > > In my application, a Request has many Histories. > > > > How can I add the correct route to have something like that : > > > > /admin/requests/24/histories. > > > > > > > > Without the /admin, it would simply look like this : > > > > map.resources :requests do |request| > > > > request.resources :histories > > > > end > > > > > > > > But with the /admin, everything becomes to be confused for me. > > > > Any help would be greatly appreciated. > > > > > > > > Thanks in advance, > > > > Thomas. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >-- Ed Hickey Developer Litmus Media 816-533-0409 ehickey-A4HEbNdjHgMmlAP/+Wk3EA@public.gmane.org A Member of Think Partnership, Inc www.ThinkPartnership.com Amex ticker symbol: THK --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Yes, that''s it. But there is still an error in my solution. Here is the final (I hope) solution : map.with_options :path_prefix => "/admin", :name_prefix => "admin_" do |m| m.resources :requests, :controller => "admin/requests" do |request| request.resources :histories, :path_prefix => "/admin/requests/:request_id", :name_prefix => "admin_", :controller => "admin/histories" end end In my previous solution, I forgot ":controller => "admin/histories". Thanks for your help. Everybody is still welcome to comment this solution. Thomas. On 2/2/07, Ed Hickey <bassnode-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > so if you do this: > <%= admin_histories_url(@request) %> > > you should get something like: > "/admin/requests/1/histories" > > if you do this: > <%= admin_histories_url(@request, @history) %> > > you should get something like: > "/admin/requests/1/histories/2" > > > You have achieved what you requested in your original email, no? > > ed > > On 2/2/07, Thomas Balthazar <thomas.tmp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > It seems to work with this in my route.rb : > > map.with_options :path_prefix => "/admin", :name_prefix => "admin_" do > |m| > > m.resources :requests, :controller => "admin/requests" do |request| > > request.resources :histories, :path_prefix => > > "/admin/requests/:request_id", :name_prefix => "admin_" > > end > > end > > > > If I try that in my view : > > <%= admin_histories_url(@request) %><br /> > > > > I now get this : > > http://0.0.0.0:3000/admin/requests/24/histories > > > > If anybody wants to comment this solution, he is more than welcome. > > I''m not sure to do the right thing here. > > > > Thanks, > > Thomas. > > > > > > > > > > On 2/2/07, Thomas Balthazar <thomas.tmp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hello Ed, > > > Thanks for your answer. > > > > > > When I do this : > > > map.with_options :path_prefix => "/admin", :name_prefix => "admin_" > do > > |m| > > > m.resources :requests, :controller => "admin/requests" do > |request| > > > request.resources :histories > > > end > > > end > > > > > > And in my view I do this : > > > <%= admin_histories_url %> > > > > > > I get this error : > > > undefined local variable or method `admin_histories_url'' > > > > > > So I''ve changed to that : > > > map.with_options :path_prefix => "/admin", :name_prefix => "admin_" > do > > |m| > > > m.resources :histories, :controller => "admin/histories" > > > m.resources :requests, :controller => "admin/requests" do > |request| > > > request.resources :histories > > > end > > > end > > > > > > And now : <%= admin_histories_url %> give me this : > > http://0.0.0.0:3000/admin/histories > > > > > > If I try this in my view : > > > <%= admin_histories_url(@request) %> > > > > > > I get this error : > > > You have a nil object when you didn''t expect it! > > > The error occurred while evaluating nil.to_sym > > > > > > So I don''t think it solves the problem. > > > Any idea? > > > Thanks, > > > Thomas. > > > > > > > > > > > > On 2/2/07, Ed Hickey < bassnode-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > try this: > > > > > > > > map.with_options :path_prefix => "/admin", :name_prefix => "admin_" > do > > |m| > > > > m.resources :requests, :controller => "admin/requests" do |req| > > > > req.resources :histories > > > > end > > > > end > > > > > > > > > > > > ed > > > > > > > > > > > > On 2/2/07, Thomas Balthazar < thomas.tmp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hello, > > > > > > > > > > I''m now playing with REST and Rails (with Rails 1.2.1). > > > > > > > > > > I have the following routes in my route.rb : > > > > > > > > > > map.with_options :path_prefix => "/admin", :name_prefix => > "admin_" do > > |m| > > > > > m.resources :requests, :controller => "admin/requests" > > > > > end > > > > > > > > > > This give me a RESTful /admin/requests controller. > > > > > > > > > > In my application, a Request has many Histories. > > > > > How can I add the correct route to have something like that : > > > > > /admin/requests/24/histories. > > > > > > > > > > Without the /admin, it would simply look like this : > > > > > map.resources :requests do |request| > > > > > request.resources :histories > > > > > end > > > > > > > > > > But with the /admin, everything becomes to be confused for me. > > > > > Any help would be greatly appreciated. > > > > > > > > > > Thanks in advance, > > > > > Thomas. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > Ed Hickey > Developer > Litmus Media > 816-533-0409 > ehickey-A4HEbNdjHgMmlAP/+Wk3EA@public.gmane.org > A Member of Think Partnership, Inc > www.ThinkPartnership.com > Amex ticker symbol: THK > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I ran across this the other day and was confused about why the with_options options don''t trickle down but I guess it doesn''t actually matter why since they _don''t_. RSL On 2/2/07, Thomas Balthazar <thomas.tmp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Yes, that''s it. > But there is still an error in my solution. > > Here is the final (I hope) solution : > map.with_options :path_prefix => "/admin", :name_prefix => "admin_" do > |m| > m.resources :requests, :controller => "admin/requests" do |request| > request.resources :histories, :path_prefix => > "/admin/requests/:request_id", :name_prefix => "admin_", :controller => > "admin/histories" > end > end > > In my previous solution, I forgot ":controller => "admin/histories". > Thanks for your help. > > Everybody is still welcome to comment this solution. > Thomas. > > On 2/2/07, Ed Hickey <bassnode-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > so if you do this: > > <%= admin_histories_url(@request) %> > > > > you should get something like: > > "/admin/requests/1/histories" > > > > if you do this: > > <%= admin_histories_url(@request, @history) %> > > > > you should get something like: > > "/admin/requests/1/histories/2" > > > > > > You have achieved what you requested in your original email, no? > > > > ed > > > > On 2/2/07, Thomas Balthazar < thomas.tmp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > It seems to work with this in my route.rb : > > > map.with_options :path_prefix => "/admin", :name_prefix => "admin_" > > do |m| > > > m.resources :requests, :controller => "admin/requests" do > > |request| > > > request.resources :histories, :path_prefix => > > > "/admin/requests/:request_id", :name_prefix => "admin_" > > > end > > > end > > > > > > If I try that in my view : > > > <%= admin_histories_url(@request) %><br /> > > > > > > I now get this : > > > http://0.0.0.0:3000/admin/requests/24/histories > > > > > > If anybody wants to comment this solution, he is more than welcome. > > > I''m not sure to do the right thing here. > > > > > > Thanks, > > > Thomas. > > > > > > > > > > > > > > > On 2/2/07, Thomas Balthazar <thomas.tmp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hello Ed, > > > > Thanks for your answer. > > > > > > > > When I do this : > > > > map.with_options :path_prefix => "/admin", :name_prefix => > > "admin_" do > > > |m| > > > > m.resources :requests, :controller => "admin/requests" do > > |request| > > > > request.resources :histories > > > > end > > > > end > > > > > > > > And in my view I do this : > > > > <%= admin_histories_url %> > > > > > > > > I get this error : > > > > undefined local variable or method `admin_histories_url'' > > > > > > > > So I''ve changed to that : > > > > map.with_options :path_prefix => "/admin", :name_prefix => > > "admin_" do > > > |m| > > > > m.resources :histories, :controller => "admin/histories" > > > > m.resources :requests, :controller => "admin/requests" do > > |request| > > > > request.resources :histories > > > > end > > > > end > > > > > > > > And now : <%= admin_histories_url %> give me this : > > > http://0.0.0.0:3000/admin/histories > > > > > > > > If I try this in my view : > > > > <%= admin_histories_url(@request) %> > > > > > > > > I get this error : > > > > You have a nil object when you didn''t expect it! > > > > The error occurred while evaluating nil.to_sym > > > > > > > > So I don''t think it solves the problem. > > > > Any idea? > > > > Thanks, > > > > Thomas. > > > > > > > > > > > > > > > > On 2/2/07, Ed Hickey < bassnode-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > > try this: > > > > > > > > > > map.with_options :path_prefix => "/admin", :name_prefix => > > "admin_" do > > > |m| > > > > > m.resources :requests, :controller => "admin/requests" do |req| > > > > > req.resources :histories > > > > > end > > > > > end > > > > > > > > > > > > > > > ed > > > > > > > > > > > > > > > On 2/2/07, Thomas Balthazar < thomas.tmp-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > Hello, > > > > > > > > > > > > I''m now playing with REST and Rails (with Rails 1.2.1). > > > > > > > > > > > > I have the following routes in my route.rb : > > > > > > > > > > > > map.with_options :path_prefix => "/admin", :name_prefix => > > "admin_" do > > > |m| > > > > > > m.resources :requests, :controller => "admin/requests" > > > > > > end > > > > > > > > > > > > This give me a RESTful /admin/requests controller. > > > > > > > > > > > > In my application, a Request has many Histories. > > > > > > How can I add the correct route to have something like that : > > > > > > /admin/requests/24/histories. > > > > > > > > > > > > Without the /admin, it would simply look like this : > > > > > > map.resources :requests do |request| > > > > > > request.resources :histories > > > > > > end > > > > > > > > > > > > But with the /admin, everything becomes to be confused for me. > > > > > > Any help would be greatly appreciated. > > > > > > > > > > > > Thanks in advance, > > > > > > Thomas. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > Ed Hickey > > Developer > > Litmus Media > > 816-533-0409 > > ehickey-A4HEbNdjHgMmlAP/+Wk3EA@public.gmane.org > > A Member of Think Partnership, Inc > > www.ThinkPartnership.com > > Amex ticker symbol: THK > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---