ZoolWay wrote: > Hello, > > I just started ruby on rails a week ago and know cannot find any > information which helps me for my desired routing. At the moment I > cannot image that this should be too hard. > > I'd like to use urls like the following to display a simple page: > domain.com/customer/features > domain.com/customer/screenshots > domain.com/customer/order > domain.com/partner/features > domain.com/partner/screenshots > domain.com/partner/order > domain.com/contact > domain.com/disclaimer > domain.com/home > > This is deadly simple possible using sinatra with the following > routes: > get '/' do > MyClass::MyMethod() > end > > get '/:pageTitle' do > MyClass::ShowPage(params[:pageTitle], nil) > end > > get '/:audienceTitle/:pageTitle' do > MyClass::ShowPage(params[:pageTitle], params[:audienceTitle]) > end > > In MyClass::ShowPage() I can do the necessary lookup for the page > depending on provided parameters. > Unfortunately I don't know how to pass part of the url as param to my > routing. I tried this and similars in routes.rb: > map.foo 'foo/:pageTitle', :controller => 'pages', :action => > 'show', :id => Page.find_by_pageTitle(:pageTitle)[0].id > > But this does not work. And please, I do not want to start discussion > about permalink pro/con ;) > > Thanks in advance for any help, > - ZoolWay
Hey ZoolWay I you shouldn't be calling find in your routes file at all. try map.connect "foo/:pageTitle", :controller => "pages", :action => "show" and then in your show action you can use: Page.find_by_pageTitle(:pageTitle) Also - I would try to stick to the convention of underscoring column names rather than camelCase. Gavin http://handyrailstips.com -- 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

