This is probably a very basic question, but what is the proper controller & routing setup if I''m setting up a RoR site with static pages, like: http://mysite.com/about http://mysite.com/services http://mysite.com/contact I want each of these pages to use a single template file that I can push content to. It seems like overkill to create individual controllers for about, services, and contact, so what is the best way to set this up? -- Posted via http://www.ruby-forum.com/.
You either configure routes mapping (routes.rb) and use just one controller and define in each action a diferent template with the render command or you create differnt controllers, which is much simpler. It mainly depends on how you want to group things together. On 4/21/06, Brandon S. <bms@slantmultimedia.com> wrote:> > This is probably a very basic question, but what is the proper > controller & routing setup if I''m setting up a RoR site with static > pages, like: > > http://mysite.com/about > http://mysite.com/services > http://mysite.com/contact > > I want each of these pages to use a single template file that I can push > content to. It seems like overkill to create individual controllers for > about, services, and contact, so what is the best way to set this up? > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Roberto Saccon -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060421/30cd07b4/attachment.html
Brandon S. wrote:> This is probably a very basic question, but what is the proper > controller & routing setup if I''m setting up a RoR site with static > pages, like: > > http://mysite.com/about > http://mysite.com/services > http://mysite.com/contact > > I want each of these pages to use a single template file that I can push > content to. It seems like overkill to create individual controllers for > about, services, and contact, so what is the best way to set this up?What I''ve done is create a simple controller called "site" which will group all my contact/about/privacy terms/etc pages together. Then I use routes to direct "/about" to "/site/about": map.contact ''/contact'', :controller => ''site'', :action => ''contact'' map.about ''/about'', :controller => ''site'', :action => ''about'' map.terms ''/terms'', :controller => ''site'', :action => ''terms'' map.privacy ''/privacy'', :controller => ''site'', :action => ''privacy'' Jeff Coleman -- Posted via http://www.ruby-forum.com/.
Roberto, Thanks for the info... I would like to have one design template and push content from each page to the template, so it seems like the single controller is the way to go... does anyone have other thoughts? Brandon -- Posted via http://www.ruby-forum.com/.
Jeff Coleman wrote:> > What I''ve done is create a simple controller called "site" which will > group all my contact/about/privacy terms/etc pages together. Then I use > routes to direct "/about" to "/site/about": > > map.contact ''/contact'', :controller => ''site'', :action => ''contact'' > map.about ''/about'', :controller => ''site'', :action => ''about'' > map.terms ''/terms'', :controller => ''site'', :action => ''terms'' > map.privacy ''/privacy'', :controller => ''site'', :action => ''privacy'' > > Jeff ColemanJeff... awesome! That sounds like a good solution. I''ll try it out. -- Posted via http://www.ruby-forum.com/.