Homepage instead of welcome page?


#1

Got a noob question for ya…

When I visit http://localhost:3000/
I get the nice “Welcome to rails” page. To get to a controller I have to
go to:
http://localhost:3000/controllername

What if I don’t want the welcome message and want / to resolve to a
controller?

How do I set that up?

Thanks,

Dave


#2

On 2/7/06, David C. removed_email_address@domain.invalid wrote:

How do I set that up?
One way to do it is to define a route for ‘/’.

As the last entry in routes.rb, add something like this:

map.connect ‘/’, :controller => ‘mycontroller’, :action => ‘someaction’

You’ll have to get rid of index.html in the /public directory or that
file will show instead. I don’t really understand why index.html gets
shown in that case, so if someone could explain that piece of it I’d
appreciate it.

– James


#3

map.connect ‘/’, :controller => ‘mycontroller’, :action => ‘someaction’

Thanks, I’ll try that tonight!


#4

You’ll have to get rid of index.html in the /public directory or that
file will show instead. I don’t really understand why index.html gets
shown in that case, so if someone could explain that piece of it I’d
appreciate it.

Because Rails uses 404 rerouting to work, at least in most of the
set-ups
I’ve seen… if the file exists (in this case. index.html) it gets
shown -
if it doesn’t exist, the URL is passed as a 404 to the (F/S)CGI script,
which looks at the URL, compares it to routes.rb, and picks the correct
controller and action to run.

-Will


#5

first you have to delete the index.html file in you application’s public
directory.
then you edit the routes.rb file and create a route that reads like the
following:

map.connect ‘’, :controller => “controller_name”


#6

What if I don’t want the welcome message and want / to resolve to a
controller?

How do I set that up?

Did you read the welcome message???

qoute: Set up a default route and remove or rename this file :wink:

Mikkel B.

www.strongside.dk - Football Portal(DK)
nflfeed.helenius.org - Football News(DK)
ting.minline.dk - Buy Old Stuff!(DK)