db--
2010-Jun-07 17:47 UTC
How to add dynamic routes to routes.rb. Worked in rails2 doesn''t work in rails3
I''ve the following solution for this in rails2 In config/routes.rb Page.all.each do |page| map.connect page.url, :controller => p.controller, :action => p.action # get page.url + '' => '' + p.controller+''#''+p.action end This worked in rails2 but in rails3 this doesn''t work anymore. I do get "rake routes" display my route but app.get(''/test/page'') doesn''t work. I guess it has something to do with the parsing of my Page class, as not only map.method is relevant, but also any word inside that block. Could somebody help? best, dennis -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
pepe
2010-Jun-08 08:29 UTC
Re: How to add dynamic routes to routes.rb. Worked in rails2 doesn''t work in rails3
Do you have a typo and ''p.'' needs to be replaced with ''page.''? On Jun 7, 1:47 pm, db-- <d...-ag90wA1KqrqbacvFa/9K2g@public.gmane.org> wrote:> I''ve the following solution for this in rails2 > > In config/routes.rb > > Page.all.each do |page| > map.connect page.url, :controller => p.controller, :action => > p.action > # get page.url + '' => '' + p.controller+''#''+p.action > end > > This worked in rails2 but in rails3 this doesn''t work anymore. I do > get "rake routes" display my route but app.get(''/test/page'') doesn''t > work. I guess it has something to do with the parsing of my Page > class, as not only map.method is relevant, but also any word inside > that block. > > Could somebody help? > > best, > > dennis-- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
dennis berger
2010-Jun-08 09:36 UTC
Re: Re: How to add dynamic routes to routes.rb. Worked in rails2 doesn''t work in rails3
I works now, but I had to add the following to my config/route.rb ----------- require ''arel'' require ''active_model'' require ''active_model/observing'' ------------ Otherwise my route got added but no route at all will work. app.get(''/page/about'') AND app.get(''/'') resulted in unintialized constants error. best, dennis Am 08.06.2010 um 10:29 schrieb pepe:> Do you have a typo and ''p.'' needs to be replaced with ''page.''? > > On Jun 7, 1:47 pm, db-- <d...-ag90wA1KqrqbacvFa/9K2g@public.gmane.org> wrote: >> I''ve the following solution for this in rails2 >> >> In config/routes.rb >> >> Page.all.each do |page| >> map.connect page.url, :controller => p.controller, :action => >> p.action >> # get page.url + '' => '' + p.controller+''#''+p.action >> end >> >> This worked in rails2 but in rails3 this doesn''t work anymore. I do >> get "rake routes" display my route but app.get(''/test/page'') doesn''t >> work. I guess it has something to do with the parsing of my Page >> class, as not only map.method is relevant, but also any word inside >> that block. >> >> Could somebody help? >> >> best, >> >> dennis > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >Dennis Berger Informatik email: db-ag90wA1KqrqbacvFa/9K2g@public.gmane.org mobile: +491791231509 fon: +494054001817 -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
dennis berger
2010-Jun-08 09:46 UTC
Re: Re: How to add dynamic routes to routes.rb. Worked in rails2 doesn''t work in rails3
unfortunately the tests didn''t find the routes: 1) Error: test_should_get_about(PageControllerTest): ActionController::RoutingError: No route matches {:action=>"about", :controller=>"page"} /test/functional/page_controller_test.rb:5:in `test_should_get_about'' $ rake routes RAILS_ENV=test (in xxx) page_index /page/index {:controller=>"page", :action=>"index"} page_about /page/about {:controller=>"page", :action=>"about"} :-/ best, dennis Am 08.06.2010 um 11:36 schrieb dennis berger:> I works now, but I had to add the following to my config/route.rb > > ----------- > require ''arel'' > require ''active_model'' > require ''active_model/observing'' > ------------ > > Otherwise my route got added but no route at all will work. > > app.get(''/page/about'') AND app.get(''/'') resulted in unintialized constants error. > > > best, > > dennis > > > > Am 08.06.2010 um 10:29 schrieb pepe: > >> Do you have a typo and ''p.'' needs to be replaced with ''page.''? >> >> On Jun 7, 1:47 pm, db-- <d...-ag90wA1KqrqbacvFa/9K2g@public.gmane.org> wrote: >>> I''ve the following solution for this in rails2 >>> >>> In config/routes.rb >>> >>> Page.all.each do |page| >>> map.connect page.url, :controller => p.controller, :action => >>> p.action >>> # get page.url + '' => '' + p.controller+''#''+p.action >>> end >>> >>> This worked in rails2 but in rails3 this doesn''t work anymore. I do >>> get "rake routes" display my route but app.get(''/test/page'') doesn''t >>> work. I guess it has something to do with the parsing of my Page >>> class, as not only map.method is relevant, but also any word inside >>> that block. >>> >>> Could somebody help? >>> >>> best, >>> >>> dennis >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >> > > Dennis Berger > Informatik > email: db-ag90wA1KqrqbacvFa/9K2g@public.gmane.org > mobile: +491791231509 > fon: +494054001817 > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >Dennis Berger Informatik email: db-ag90wA1KqrqbacvFa/9K2g@public.gmane.org mobile: +491791231509 fon: +494054001817 -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.