I''m racking my brain trying to get all this straight in my head. What do the settings need to be in order to show a layout on the landing page without referencing a controller. All I want to do is hit www.mypage.com and display a layout view. right now it''s pure html - no data. Everything I read shows www.mypage.com/somecontroller What are all the settings? Thanks for your help Keith --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Julian Leviston
2008-Apr-15 05:08 UTC
Re: Newbie : homepage without referencing a controller
You''re kinda garbling your jargon here a bit, which is okay. When you hit http://someurl/ rails looks in the public folder for index.html. If it finds it, it renders it. If it doesn''t, it looks in the routes.rb file (in the config folder) for a route that is hooked up to a blank string (ie the root of the site). If it find that, it grabs that route, runs the action at that route, and then renders the layout template associated with that action (if there is one - it''s either specified on the controller at the top with the layout method, or by default it will render views inside a layout with the same name as the controller, if it finds one and the layout is not specified in the controller), inserting in the results of the rendered view file template into that layout for each time it finds <%= yield %> in the layout. If it can''t find the view file, it will complain. I hope this helps. Julian. Learn Ruby on Rails! Check out the FREE VIDS (for a limited time) VIDEO #4 coming soon! http://sensei.zenunit.com/ On 15/04/2008, at 2:33 PM, kschu wrote:> > I''m racking my brain trying to get all this straight in my head. > > What do the settings need to be in order to show a layout on the > landing page without referencing a controller. > All I want to do is hit www.mypage.com and display a layout view. > right now it''s pure html - no data. Everything I read shows > www.mypage.com/somecontroller > > What are all the settings? > > Thanks for your help > Keith > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
yeah to setup the default page delete index.html from the public directory go into config/routes.rb add a ''default'' action map.connect ''/'', :controller => ''store'', :action => ''index'' Though I''m not sure about all of it :) -R -- 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 -~----------~----~----~----~------~----~------~--~---
ok here is what I did - I think I''m close deleted index.html Added to routes.rb map.connect ''/'', :controller => ''main'', :action => ''index'' I created a controller called ''main'' with the idea being I can route pages like contact or about through. In the main controller I have class MainController < ApplicationController layout(main, conditions = {}, auto = false) end when I run the app I get the error: undefined local variable or method `main'' for MainController:Class help? On Apr 15, 1:59 am, Roger Pack <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> yeah to setup the default page > delete index.html from the public directory > go into config/routes.rb > add a ''default'' action > > map.connect ''/'', > :controller => ''store'', > :action => ''index'' > > Though I''m not sure about all of it :) > -R > -- > Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---
kschu wrote:> ok here is what I did - I think I''m close > > deleted index.html > Added to routes.rb > map.connect ''/'', > :controller => ''main'', > :action => ''index'' >try using map.home instead of map.connect [?] -- 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 -~----------~----~----~----~------~----~------~--~---
> try using map.home instead of map.connect [?]something like this? map.home '''', :controller => ''home'', :action => ''index'' -- 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 -~----------~----~----~----~------~----~------~--~---
You shouldn''t need all of that in your Main controller. def index # will render app/views/main/index.html.erb end If you have a layout that you don''t want to render, you can specify render :layout => false. -Kyle On Apr 15, 9:47 am, Roger Pack <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > try using map.home instead of map.connect [?] > > something like this? > map.home '''', :controller => ''home'', :action => ''index'' > -- > Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---
Same error On Apr 15, 9:47 am, Roger Pack <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > try using map.home instead of map.connect [?] > > something like this? > map.home '''', :controller => ''home'', :action => ''index'' > -- > Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---
That did it. Thanks guys! On Apr 15, 11:18 am, Kyle <kyle.r...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You shouldn''t need all of that in your Main controller. > > def index > # will render app/views/main/index.html.erb > end > > If you have a layout that you don''t want to render, you can specify > render :layout => false. > > -Kyle > > On Apr 15, 9:47 am, Roger Pack <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > > > > try using map.home instead of map.connect [?] > > > something like this? > > map.home '''', :controller => ''home'', :action => ''index'' > > -- > > Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---
Did you remove the line that read: layout(main, conditions = {}, auto = false) ? If you have this in your routes... map.connect ''/'', :controller => ''store'', :action => ''index'' (not sure about map.home automatically routing ''/'') ...and this in your controller... class MainController < ApplicationController def index # will render app/views/main/index.html.erb end end ...and if you have the file app/views/main/index.html.erb, you should be getting something. If not, please paste the whole error. Also, check your logs to see if your request for http://www.myapp.com/ (or perhaps http://localhost:3000/) is correctly calling the :controller => ''main'', :action => ''index''. -Kyle On Apr 15, 11:19 am, kschu <keithschus...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Same error > > On Apr 15, 9:47 am, Roger Pack <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > > > > try using map.home instead of map.connect [?] > > > something like this? > > map.home '''', :controller => ''home'', :action => ''index'' > > -- > > Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---