I am new to RoR, so forgive me as I know this is fundamental, but what is the "standard" for creating basic site pages like: home, about, contact, etc. I definitely understand the MVC approach and therefore do not want to couple these pages with other components. My guess is to create a "site" controller to manage these types of pages... Not sure, so I wanted to get more direction before I make something harder. Where do I put basic site pages? How do I map these in routes.rb so they appear as mysite.com/about, but do not conflict with other rules? Thanks, Jason --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> Where do I put basic site pages?I usually do have a general container controller - I like to call it ''home''> How do I map these in routes.rb so they appear as mysite.com/about, > but do not conflict with other rules?You can create them and put them in your public directory - Rails will look there first. For example if you have an ''about'' controller and you create an about directory and create test.html in there you can then go to /about/ test Hope that helps. John --~--~---------~--~----~------------~-------~--~----~ 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 the response. I am looking for something a bit more elegant as far as the routes. I don''t want to go to home/about or home/ contact. I understand the general container controller and will adopt that practice. However, I am wondering if I can make a default rule that would allow me to go to /about, /contact, etc and they map accoardingly to the :controller => "home" as "home/:action". So I guess the question now is, can anyone tell me how to write that rule? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
in the cong directory you have a routes.rb archive there yo can arrange your routes, the default are for each controler a route is created containing the destroy, create, new , update . For example if you have a home controller this will be created: map.resources :home , this will let you access from your browser to /home/new home/edit/id home/ (the index), each of this will have a view related. On Tue, Sep 2, 2008 at 2:47 PM, Jason <mccreary.jason-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Thanks for the response. I am looking for something a bit more elegant > as far as the routes. I don''t want to go to home/about or home/ > contact. I understand the general container controller and will adopt > that practice. However, I am wondering if I can make a default rule > that would allow me to go to /about, /contact, etc and they map > accoardingly to the :controller => "home" as "home/:action". > > So I guess the question now is, can anyone tell me how to write that > rule? > > >-- Felipe Vergara Contesse Ingeniería Civil Industrial UC --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks for the reponse. I undertand the controller routing. But this is not the functionality I am after. I want a route, that defaults to a "home" controller, but doesn''t interfer with other routes. In addition, it would allow me to use URLs like /about /contact, not /home/about, /home/contact. --~--~---------~--~----~------------~-------~--~----~ 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 usually use the method shown in http://railscasts.com/episodes/117-semi-static-pages with the route being map.static '':permalink'', :controller => ''pages'', :action => ''show'' placed right above the default routes On Sep 2, 3:02 pm, Jason <mccreary.ja...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thanks for the reponse. I undertand the controller routing. But this > is not the functionality I am after. > > I want a route, that defaults to a "home" controller, but doesn''t > interfer with other routes. In addition, it would allow me to use URLs > like /about /contact, not /home/about, /home/contact.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You''ll need to add this route to your routes.rb file: map.home "home", :controller => "MyMiscController", :action => "mi_home_action" map.about "about", :controller => "MyMiscController", :action => "mi_about_action" You will have now: home_path (/home) about_path (/about) helper methods so you can link them from your view files. I can''t think of other way. Regards, Jorge Corona. On Sep 2, 2:02 pm, Jason <mccreary.ja...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thanks for the reponse. I undertand the controller routing. But this > is not the functionality I am after. > > I want a route, that defaults to a "home" controller, but doesn''t > interfer with other routes. In addition, it would allow me to use URLs > like /about /contact, not /home/about, /home/contact.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
This is a great reply, Pazole. I think it''s exactly what was needed and also helps to serve as a good example for reference. Thanks! On Sep 2, 6:14 pm, Pozole <poz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You''ll need to add this route to your routes.rb file: > > map.home "home", :controller => "MyMiscController", :action => > "mi_home_action" > map.about "about", :controller => "MyMiscController", :action => > "mi_about_action" > > You will have now: > > home_path (/home) > about_path (/about) > > helper methods so you can link them from your view files. > > I can''t think of other way. > > Regards, > Jorge Corona. > > On Sep 2, 2:02 pm, Jason <mccreary.ja...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Thanks for the reponse. I undertand the controller routing. But this > > is not the functionality I am after. > > > I want a route, that defaults to a "home" controller, but doesn''t > > interfer with other routes. In addition, it would allow me to use URLs > > like /about /contact, not /home/about, /home/contact.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Sep 3, 12:14 am, Pozole <poz...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You''ll need to add this route to your routes.rb file: > > map.home "home", :controller => "MyMiscController", :action => > "mi_home_action" > map.about "about", :controller => "MyMiscController", :action => > "mi_about_action"You could even glob the view directory for your general controller for view files and create the routes dynamically. E.g. put this in your routes.rb: ActionController::Base.view_paths.each do |path| Dir.glob("#{path}/pages/*").each do |view_file| view_name = File.basename(view_file, ''.html.erb'') map.send view_name.to_sym, view_name, :controller => ''page'', :action => view_name end end (assuming your general controller is called "pages") Cheers, Christian --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks to everyone for the replies. Extra thanks to Christian and Jorge, these are exactly what I was after. Also a good screencast from jjburka. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---