Forum: Ruby on Rails homepage instead of welcome page?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Dave C. (Guest)
on 2006-02-07 17:27
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
James L. (Guest)
on 2006-02-07 17:55
(Received via mailing list)
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
Dave C. (Guest)
on 2006-02-07 17:57
> map.connect '/', :controller => 'mycontroller', :action => 'someaction'

Thanks, I'll try that tonight!
Will B. (Guest)
on 2006-02-07 18:04
(Received via mailing list)
>
>
>
> 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
Francois P. (Guest)
on 2006-02-07 18:04
(Received via mailing list)
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"
Mikkel B. (Guest)
on 2006-02-07 20:25
(Received via mailing list)
>>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 ;-)


Mikkel B.

www.strongside.dk    - Football Portal(DK)
nflfeed.helenius.org - Football News(DK)
ting.minline.dk      - Buy Old Stuff!(DK)
This topic is locked and can not be replied to.