Hi, I am trying to create REST routes non-standard setup. The rest url helpers give an error when I try to use a module controller for a nested resource. Works map.resources :bar, :controller => ''module/bar'' Works map.resources :foos do |foo| foo.resources :bar end Doesn''t work (url helpers broken) map.resources :foos do |foo| foo.resources :bar, :controller => ''module/bar'' end The URL helper error is... ActionView::TemplateError (bar_url failed to generate from {:action=>"index", :controller=>"module/bar", :foo_id=>"1"}, expected: {:action=>"index", :controller=>"module/bar"}, diff: {:foo_id=>"1"}) Anybody have any suggestions on what is wrong? Is it just a limitation or feature of rest routes? Thanks, Stephanie --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Trevor Squires
2007-Mar-23 00:49 UTC
Re: Resources, Modules, and Nesting (URL Helper errors)
Hey, could be a pluralization issue: map.resources :foos do |foo| map.resources :bars, :controller => ''module/bar'' end note I said :bars not :bar HTH, Trevor On 22-Mar-07, at 5:07 PM, stephanie wrote:> > > Hi, > > I am trying to create REST routes non-standard setup. The rest url > helpers give an error when I try to use a module controller for a > nested resource. > > Works > map.resources :bar, :controller => ''module/bar'' > > Works > map.resources :foos do |foo| > foo.resources :bar > end > > Doesn''t work (url helpers broken) > map.resources :foos do |foo| > foo.resources :bar, :controller => ''module/bar'' > end > > The URL helper error is... > ActionView::TemplateError (bar_url failed to generate from > {:action=>"index", :controller=>"module/bar", :foo_id=>"1"}, expected: > {:action=>"index", :controller=>"module/bar"}, diff: {:foo_id=>"1"}) > > Anybody have any suggestions on what is wrong? Is it just a limitation > or feature of rest routes? > > Thanks, > Stephanie > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi Trever, Thanks for the reply. Sorry for the typo. My email should say bars (a typo in translation to a question). map.resources :bars, :controller => ''module/bars My code actually did have the right pluralization. I copied the code out of the nesting and tested it unnested. All of the helpers worked with a module resource it isn''t nested. -Stephanie '' On Mar 22, 5:49 pm, Trevor Squires <tre...-k8q5a0yEZAgS+FvcfC7Uqw@public.gmane.org> wrote:> Hey, > > could be a pluralization issue: > > map.resources :foos do |foo| > map.resources :bars, :controller => ''module/bar'' > end > > note I said :bars not :bar > > HTH, > Trevor > > On 22-Mar-07, at 5:07 PM, stephanie wrote: > > > > > Hi, > > > I am trying to create REST routes non-standard setup. The rest url > > helpers give an error when I try to use a module controller for a > > nested resource. > > > Works > > map.resources :bar, :controller => ''module/bar'' > > > Works > > map.resources :foos do |foo| > > foo.resources :bar > > end > > > Doesn''t work (url helpers broken) > > map.resources :foos do |foo| > > foo.resources :bar, :controller => ''module/bar'' > > end > > > The URL helper error is... > > ActionView::TemplateError (bar_url failed to generate from > > {:action=>"index", :controller=>"module/bar", :foo_id=>"1"}, expected: > > {:action=>"index", :controller=>"module/bar"}, diff: {:foo_id=>"1"}) > > > Anybody have any suggestions on what is wrong? Is it just a limitation > > or feature of rest routes? > > > Thanks, > > Stephanie--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Trevor Squires
2007-Mar-23 01:43 UTC
Re: Resources, Modules, and Nesting (URL Helper errors)
Hey Stephanie, interesting... to be honest I''m not even trying it out with a controller inside a module because the error you''re getting seems to be coming from the url_helpers, which don''t care about controllers as such. So, at the risk of sending you on a wild goose chase, I''ll make a guess: I''m betting you''ve got "map.resources :bars" in more than one place in your routes.rb - am I right? Trevor On 22-Mar-07, at 6:07 PM, stephanie wrote:> > > Hi Trever, > > Thanks for the reply. Sorry for the typo. My email should say bars (a > typo in translation to a question). > > map.resources :bars, :controller => ''module/bars > > My code actually did have the right pluralization. I copied the code > out of the nesting and tested it unnested. All of the helpers worked > with a module resource it isn''t nested. > > -Stephanie > > '' > > On Mar 22, 5:49 pm, Trevor Squires <tre...-k8q5a0yEZAgS+FvcfC7Uqw@public.gmane.org> wrote: >> Hey, >> >> could be a pluralization issue: >> >> map.resources :foos do |foo| >> map.resources :bars, :controller => ''module/bar'' >> end >> >> note I said :bars not :bar >> >> HTH, >> Trevor >> >> On 22-Mar-07, at 5:07 PM, stephanie wrote: >> >> >> >>> Hi, >> >>> I am trying to create REST routes non-standard setup. The rest url >>> helpers give an error when I try to use a module controller for a >>> nested resource. >> >>> Works >>> map.resources :bar, :controller => ''module/bar'' >> >>> Works >>> map.resources :foos do |foo| >>> foo.resources :bar >>> end >> >>> Doesn''t work (url helpers broken) >>> map.resources :foos do |foo| >>> foo.resources :bar, :controller => ''module/bar'' >>> end >> >>> The URL helper error is... >>> ActionView::TemplateError (bar_url failed to generate from >>> {:action=>"index", :controller=>"module/bar", :foo_id=>"1"}, >>> expected: >>> {:action=>"index", :controller=>"module/bar"}, diff: {:foo_id=>"1"}) >> >>> Anybody have any suggestions on what is wrong? Is it just a >>> limitation >>> or feature of rest routes? >> >>> Thanks, >>> Stephanie > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks for trying to track this down. I have no other references to :bars in the routes. I also do not have /:controller/:action/:id as a route. However, in my controllers folder I do have a app/controllers/bars_controller.rb app/controllers/foo/bars_controller.rb (this is subclassed from controllers/bars_controller.rb) Could this be causing the problem? -Stephanie On Mar 22, 6:43 pm, Trevor Squires <tre...-k8q5a0yEZAgS+FvcfC7Uqw@public.gmane.org> wrote:> Hey Stephanie, > > interesting... > > to be honest I''m not even trying it out with a controller inside a > module because the error you''re getting seems to be coming from the > url_helpers, which don''t care about controllers as such. > > So, at the risk of sending you on a wild goose chase, I''ll make a guess: > > I''m betting you''ve got "map.resources :bars" in more than one place > in your routes.rb - am I right? > > Trevor > > On 22-Mar-07, at 6:07 PM, stephanie wrote: > > > > > Hi Trever, > > > Thanks for the reply. Sorry for the typo. My email should say bars (a > > typo in translation to a question). > > > map.resources :bars, :controller => ''module/bars > > > My code actually did have the right pluralization. I copied the code > > out of the nesting and tested it unnested. All of the helpers worked > > with a module resource it isn''t nested. > > > -Stephanie > > > '' > > > On Mar 22, 5:49 pm, Trevor Squires <tre...-k8q5a0yEZAgS+FvcfC7Uqw@public.gmane.org> wrote: > >> Hey, > > >> could be a pluralization issue: > > >> map.resources :foos do |foo| > >> map.resources :bars, :controller => ''module/bar'' > >> end > > >> note I said :bars not :bar > > >> HTH, > >> Trevor > > >> On 22-Mar-07, at 5:07 PM, stephanie wrote: > > >>> Hi, > > >>> I am trying to create REST routes non-standard setup. The rest url > >>> helpers give an error when I try to use a module controller for a > >>> nested resource. > > >>> Works > >>> map.resources :bar, :controller => ''module/bar'' > > >>> Works > >>> map.resources :foos do |foo| > >>> foo.resources :bar > >>> end > > >>> Doesn''t work (url helpers broken) > >>> map.resources :foos do |foo| > >>> foo.resources :bar, :controller => ''module/bar'' > >>> end > > >>> The URL helper error is... > >>> ActionView::TemplateError (bar_url failed to generate from > >>> {:action=>"index", :controller=>"module/bar", :foo_id=>"1"}, > >>> expected: > >>> {:action=>"index", :controller=>"module/bar"}, diff: {:foo_id=>"1"}) > > >>> Anybody have any suggestions on what is wrong? Is it just a > >>> limitation > >>> or feature of rest routes? > > >>> Thanks, > >>> Stephanie--~--~---------~--~----~------------~-------~--~----~ 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 tried changing the super controller to another name. That way the only bars controller would be foo/bars_controller.rb. This still gave me the same URL helper problems as described above. I am back to suspecting is modules + nested resources is the problem??? -Stephanie On Mar 22, 7:53 pm, "stephanie" <ginorm...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thanks for trying to track this down. I have no other references > to :bars in the routes. I also do not have /:controller/:action/:id as > a route. > > However, in my controllers folder I do have a > > app/controllers/bars_controller.rb > app/controllers/foo/bars_controller.rb (this is subclassed from > controllers/bars_controller.rb) > > Could this be causing the problem? > > -Stephanie > > On Mar 22, 6:43 pm, Trevor Squires <tre...-k8q5a0yEZAgS+FvcfC7Uqw@public.gmane.org> wrote: > > > Hey Stephanie, > > > interesting... > > > to be honest I''m not even trying it out with a controller inside a > > module because the error you''re getting seems to be coming from the > > url_helpers, which don''t care about controllers as such. > > > So, at the risk of sending you on a wild goose chase, I''ll make a guess: > > > I''m betting you''ve got "map.resources :bars" in more than one place > > in your routes.rb - am I right? > > > Trevor > > > On 22-Mar-07, at 6:07 PM, stephanie wrote: > > > > Hi Trever, > > > > Thanks for the reply. Sorry for the typo. My email should say bars (a > > > typo in translation to a question). > > > > map.resources :bars, :controller => ''module/bars > > > > My code actually did have the right pluralization. I copied the code > > > out of the nesting and tested it unnested. All of the helpers worked > > > with a module resource it isn''t nested. > > > > -Stephanie > > > > '' > > > > On Mar 22, 5:49 pm, Trevor Squires <tre...-k8q5a0yEZAgS+FvcfC7Uqw@public.gmane.org> wrote: > > >> Hey, > > > >> could be a pluralization issue: > > > >> map.resources :foos do |foo| > > >> map.resources :bars, :controller => ''module/bar'' > > >> end > > > >> note I said :bars not :bar > > > >> HTH, > > >> Trevor > > > >> On 22-Mar-07, at 5:07 PM, stephanie wrote: > > > >>> Hi, > > > >>> I am trying to create REST routes non-standard setup. The rest url > > >>> helpers give an error when I try to use a module controller for a > > >>> nested resource. > > > >>> Works > > >>> map.resources :bar, :controller => ''module/bar'' > > > >>> Works > > >>> map.resources :foos do |foo| > > >>> foo.resources :bar > > >>> end > > > >>> Doesn''t work (url helpers broken) > > >>> map.resources :foos do |foo| > > >>> foo.resources :bar, :controller => ''module/bar'' > > >>> end > > > >>> The URL helper error is... > > >>> ActionView::TemplateError (bar_url failed to generate from > > >>> {:action=>"index", :controller=>"module/bar", :foo_id=>"1"}, > > >>> expected: > > >>> {:action=>"index", :controller=>"module/bar"}, diff: {:foo_id=>"1"}) > > > >>> Anybody have any suggestions on what is wrong? Is it just a > > >>> limitation > > >>> or feature of rest routes? > > > >>> Thanks, > > >>> Stephanie--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Trevor Squires
2007-Mar-23 05:34 UTC
Re: Resources, Modules, and Nesting (URL Helper errors)
Stephanie, I''m confident that the names of your controllers isn''t the source of the problem - I can use utterly bogus controller names (and modules) in map.resources calls and it has no effect on url helpers. Is this something as simple as that you''re not actually passing all the required information to the url helpers for your nested resource? As in: bar_url(''a_foo'', ''a_bar'') #=> http//host.com/foos/a_foo/bars/a_bar Trevor On 22-Mar-07, at 8:04 PM, stephanie wrote:> > > I tried changing the super controller to another name. That way the > only bars controller would be foo/bars_controller.rb. This still gave > me the same URL helper problems as described above. > > I am back to suspecting is modules + nested resources is the > problem??? > > -Stephanie > > On Mar 22, 7:53 pm, "stephanie" <ginorm...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> Thanks for trying to track this down. I have no other references >> to :bars in the routes. I also do not >> have /:controller/:action/:id as >> a route. >> >> However, in my controllers folder I do have a >> >> app/controllers/bars_controller.rb >> app/controllers/foo/bars_controller.rb (this is subclassed from >> controllers/bars_controller.rb) >> >> Could this be causing the problem? >> >> -Stephanie >> >> On Mar 22, 6:43 pm, Trevor Squires <tre...-k8q5a0yEZAgS+FvcfC7Uqw@public.gmane.org> wrote: >> >>> Hey Stephanie, >> >>> interesting... >> >>> to be honest I''m not even trying it out with a controller inside a >>> module because the error you''re getting seems to be coming from the >>> url_helpers, which don''t care about controllers as such. >> >>> So, at the risk of sending you on a wild goose chase, I''ll make a >>> guess: >> >>> I''m betting you''ve got "map.resources :bars" in more than one place >>> in your routes.rb - am I right? >> >>> Trevor >> >>> On 22-Mar-07, at 6:07 PM, stephanie wrote: >> >>>> Hi Trever, >> >>>> Thanks for the reply. Sorry for the typo. My email should say >>>> bars (a >>>> typo in translation to a question). >> >>>> map.resources :bars, :controller => ''module/bars >> >>>> My code actually did have the right pluralization. I copied the >>>> code >>>> out of the nesting and tested it unnested. All of the helpers >>>> worked >>>> with a module resource it isn''t nested. >> >>>> -Stephanie >> >>>> '' >> >>>> On Mar 22, 5:49 pm, Trevor Squires <tre...-k8q5a0yEZAgS+FvcfC7Uqw@public.gmane.org> wrote: >>>>> Hey, >> >>>>> could be a pluralization issue: >> >>>>> map.resources :foos do |foo| >>>>> map.resources :bars, :controller => ''module/bar'' >>>>> end >> >>>>> note I said :bars not :bar >> >>>>> HTH, >>>>> Trevor >> >>>>> On 22-Mar-07, at 5:07 PM, stephanie wrote: >> >>>>>> Hi, >> >>>>>> I am trying to create REST routes non-standard setup. The rest >>>>>> url >>>>>> helpers give an error when I try to use a module controller for a >>>>>> nested resource. >> >>>>>> Works >>>>>> map.resources :bar, :controller => ''module/bar'' >> >>>>>> Works >>>>>> map.resources :foos do |foo| >>>>>> foo.resources :bar >>>>>> end >> >>>>>> Doesn''t work (url helpers broken) >>>>>> map.resources :foos do |foo| >>>>>> foo.resources :bar, :controller => ''module/bar'' >>>>>> end >> >>>>>> The URL helper error is... >>>>>> ActionView::TemplateError (bar_url failed to generate from >>>>>> {:action=>"index", :controller=>"module/bar", :foo_id=>"1"}, >>>>>> expected: >>>>>> {:action=>"index", :controller=>"module/bar"}, diff: >>>>>> {:foo_id=>"1"}) >> >>>>>> Anybody have any suggestions on what is wrong? Is it just a >>>>>> limitation >>>>>> or feature of rest routes? >> >>>>>> Thanks, >>>>>> Stephanie > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi Stephanie, Have found a solution to your problem? I have the same problem as well. My routing looks as follows; map.resources :pictures, :controller => ''user_pictures'', :path_prefix => ''/:user_uid'', :name_prefix => ''user_'', :requirements => { :user_uid => /shafeer/ } do |picture| picture.resources :exhibitions, :controller => ''picture_exhibitions'', :name_prefix => ''user_picture_'' end and then; map.resource :myapp, :controller => ''myapp/index'' do |myapp| myapp.resources :pictures, :controller => ''myapp/pictures'', :name_prefix => ''myapp_'' do |picture| picture.resources :exhibitions, :controller => ''myapp/picture_exhibitions'', :name_prefix => ''myapp_picture_'' end end The helper method myapp_pictures_path produces the right path #=> http://host.com/myapp/pictures. But the problem I have is with the controller, the routing chooses the wrong controller, that is, /app/controllers/user_pictures_controller.rb instead of /app/controllers/myapp/pictures_controller.rb Any idea why is that? Thanks and Regards, Shafeer. -- Posted via http://www.ruby-forum.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 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 -~----------~----~----~----~------~----~------~--~---