Newbie : homepage without referencing a controller

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'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/

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 :slight_smile:
-R

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?

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 [?]

try using map.home instead of map.connect [?]

something like this?
map.home '', :controller => 'home', :action => 'index'

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

Same error

That did it. Thanks guys!

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