Rails producing the / page

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

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

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

Hi Dan

What I want is for the index page of the server to be generated from
rails, is 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 :slight_smile:

Thanks

Jonathan

Jonathan G. [email protected] 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/ 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://www.kreeti.com
Read my blog at: http://cuttingtheredtape.blogspot.com/
,----
| “War is Peace! Freedom is Slavery! Ignorance is Strength!”
| – Orwell, 1984, 1948
`----

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

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

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

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs