# Rails producing the / page

**URL:** <https://www.ruby-forum.com/t/rails-producing-the-page/58768>\
**Category:** Rails\
**Created:** [April 25, 2006, 7:35pm UTC](https://www.ruby-forum.com/t/rails-producing-the-page/58768 "2006-04-25T19:35:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jgeggatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e99b99/32.png) [@jgeggatt](https://www.ruby-forum.com/u/jgeggatt)\
**Post date:** [April 25, 2006, 7:35pm UTC](https://www.ruby-forum.com/t/rails-producing-the-page/58768/1 "2006-04-25T19:35:16Z")

</div>

Hi all

Very simple question, im sure, but I cant find docs anywhere that tell  
me how to do this.

What I want is for the index page of the server to be generated from  
rails, is [www.wibble.com/](http://www.wibble.com/) will result in a page that has been processed  
by rails, has the templates etc.

> From what I can see, the index page comes from public/index.html How do  
> I get this to be a rails page?

Thanks

Jonathan G.

---

<div class="post-metadata">

**Author:** ![jgeggatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e99b99/32.png) [@jgeggatt](https://www.ruby-forum.com/u/jgeggatt)\
**Post date:** [April 25, 2006, 7:41pm UTC](https://www.ruby-forum.com/t/rails-producing-the-page/58768/2 "2006-04-25T19:41:17Z")

</div>

Rails pages are handled by routes, and there is no route that matches  
the root of the domain by default.

in config/routes.rb

map.connect ‘’,  
:controller =\> ‘my\_controller’,  
:action =\> ‘index’

Then delete public/index.html since it will interfer with the routing.

Jonathan G. wrote:

> Hi all
> 
> Very simple question, im sure, but I cant find docs anywhere that tell  
> me how to do this.
> 
> What I want is for the index page of the server to be generated from  
> rails, is [www.wibble.com/](http://www.wibble.com/) will result in a page that has been processed  
> by rails, has the templates etc.
> 
> > From what I can see, the index page comes from public/index.html How do  
> > I get this to be a rails page?
> 
> Thanks
> 
> Jonathan G.

---

<div class="post-metadata">

**Author:** ![jgeggatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e99b99/32.png) [@jgeggatt](https://www.ruby-forum.com/u/jgeggatt)\
**Post date:** [April 25, 2006, 7:41pm UTC](https://www.ruby-forum.com/t/rails-producing-the-page/58768/3 "2006-04-25T19:41:37Z")

</div>

On Wed, Apr 26, 2006 at 01:27:18AM +0800, Jonathan G. wrote:

> I get this to be a rails page?  
> In config/routes.rb, put something like this:

map.connect ‘’, :controller =\> “maincontroller”, :action =\> “index”

Naturally, you will want to change the names of the controller and the  
action to suit your own needs.

You will also want to move the current public/index.html out of the way.

Dan

–  
Daniel B.

PGP Key: ftp://ftp.slightlystrange.org/pgpkey/dan.asc  
PGP Key fingerprint: D349 B109 0EB8 2554 4D75 B79A 8B17 F97C 1622 166A  
\_  
ASCII ribbon campaign ( )  
- against HTML, vCards and X  
- proprietary attachments in e-mail / \

---

<div class="post-metadata">

**Author:** ![jgeggatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e99b99/32.png) [@jgeggatt](https://www.ruby-forum.com/u/jgeggatt)\
**Post date:** [April 25, 2006, 8:16pm UTC](https://www.ruby-forum.com/t/rails-producing-the-page/58768/4 "2006-04-25T20:16:02Z")

</div>

Hi Dan

> > What I want is for the index page of the server to be generated from  
> > rails, is [www.wibble.com/](http://www.wibble.com/) will result in a page that has been processed  
> > by rails, has the templates etc.

> In config/routes.rb, put something like this:
> 
> map.connect ‘’, :controller =\> “maincontroller”, :action =\> “index”

So if I right, say I have a controller called home that should handle  
the top level of the site I would use something like :

map.connect ‘’, :controller =\> “home”, :action =\> “index”

Is that right?

> You will also want to move the current public/index.html out of the way.

I bet I forget that bit 🙂

Thanks

Jonathan

---

<div class="post-metadata">

**Author:** ![jgeggatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e99b99/32.png) [@jgeggatt](https://www.ruby-forum.com/u/jgeggatt)\
**Post date:** [April 25, 2006, 7:57pm UTC](https://www.ruby-forum.com/t/rails-producing-the-page/58768/5 "2006-04-25T19:57:05Z")

</div>

Jonathan G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

> Hi all
> 
> Very simple question, im sure, but I cant find docs anywhere that tell  
> me how to do this.

Search in the wiki.

> What I want is for the index page of the server to be generated from  
> rails, is [www.wibble.com/](http://www.wibble.com/) will result in a page that has been processed  
> by rails, has the templates etc.
> 
> > From what I can see, the index page comes from public/index.html How do  
> > I get this to be a rails page?

Delete index.html and add the line below to the config/routes.rb file  
map.connect ‘/’, :controller =\>“my\_controller”, …

## HTH.

Surendra S.  
[http://ssinghi.kreeti.com](http://ssinghi.kreeti.com), [http://www.kreeti.com](http://www.kreeti.com)  
Read my blog at: [http://cuttingtheredtape.blogspot.com/](http://cuttingtheredtape.blogspot.com/)  
,----  
| “War is Peace! Freedom is Slavery! Ignorance is Strength!”  
| – Orwell, 1984, 1948  
`----

---

<div class="post-metadata">

**Author:** ![jgeggatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e99b99/32.png) [@jgeggatt](https://www.ruby-forum.com/u/jgeggatt)\
**Post date:** [April 25, 2006, 9:02pm UTC](https://www.ruby-forum.com/t/rails-producing-the-page/58768/6 "2006-04-25T21:02:05Z")

</div>

On Tue, 2006-04-25 at 19:47 +0100, Daniel B. wrote:

> > > In config/routes.rb, put something like this:
> > > 
> > > map.connect ‘’, :controller =\> “maincontroller”, :action =\> “index”

I usually put two lines in for this. It isn’t always needed but I had  
to have the second line for my plugin to work (broomstick). The second  
line will allow you to use url\_for and have it map back to the correct  
controller/action instead of just ‘/’. Here’s what mine looks like.

map.connect ‘/maincontroller/index’, :controller =\>  
“maincontroller”, :action =\> “index”  
map.connect ‘’, :controller =\> “maincontroller”, :action =\> “index”

The above allows you use url\_for to get the “long” version of the url  
and still lets ‘’ map back to the correct controller/action.

Charlie B.  
[www.recentrambles.com](http://www.recentrambles.com)

---

<div class="post-metadata">

**Author:** ![jgeggatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e99b99/32.png) [@jgeggatt](https://www.ruby-forum.com/u/jgeggatt)\
**Post date:** [April 25, 2006, 8:49pm UTC](https://www.ruby-forum.com/t/rails-producing-the-page/58768/7 "2006-04-25T20:49:49Z")

</div>

On Wed, Apr 26, 2006 at 01:45:23AM +0800, Jonathan G. wrote:

> So if I right, say I have a controller called home that should handle  
> the top level of the site I would use something like :
> 
> map.connect ‘’, :controller =\> “home”, :action =\> “index”
> 
> Is that right?

Yep, that would do it. Assuming you have the right action and view etc  
in place to render the home page.

> > You will also want to move the current public/index.html out of the way.
> 
> I bet I forget that bit 🙂

Heheh! If you keep getting the same index page you see now, that should  
at least serve to jog your memory!

Dan

–  
Daniel B.

PGP Key: ftp://ftp.slightlystrange.org/pgpkey/dan.asc  
PGP Key fingerprint: D349 B109 0EB8 2554 4D75 B79A 8B17 F97C 1622 166A  
\_  
ASCII ribbon campaign ( )  
- against HTML, vCards and X  
- proprietary attachments in e-mail / \

---

<div class="post-metadata">

**Author:** ![jgeggatt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e99b99/32.png) [@jgeggatt](https://www.ruby-forum.com/u/jgeggatt)\
**Post date:** [April 25, 2006, 9:11pm UTC](https://www.ruby-forum.com/t/rails-producing-the-page/58768/8 "2006-04-25T21:11:22Z")

</div>

On Tue, Apr 25, 2006 at 03:00:20PM -0400, Charlie B. wrote:

> I usually put two lines in for this. It isn’t always needed but I had to have  
> the second line for my plugin to work (broomstick). The second line will allow  
> you to use url\_for and have it map back to the correct controller/action  
> instead of just ‘/’. Here’s what mine looks like.
> 
> map.connect ‘/maincontroller/index’, :controller =\> “maincontroller”, :action  
> =\> “index”  
> map.connect ‘’, :controller =\> “maincontroller”, :action =\> “index”
> 
> The above allows you use url\_for to get the “long” version of the url and still  
> lets ‘’ map back to the correct controller/action.

Ah! That may well account for some heretofore unfathomed routing  
weirdness I have been seeing.

Thanks, Charlie!

Dan

–  
Daniel B.

PGP Key: ftp://ftp.slightlystrange.org/pgpkey/dan.asc  
PGP Key fingerprint: D349 B109 0EB8 2554 4D75 B79A 8B17 F97C 1622 166A  
\_  
ASCII ribbon campaign ( )  
- against HTML, vCards and X  
- proprietary attachments in e-mail / \
