public/index.html

Hi --

I'm very new to rails. I have a couple of what have to be very naive questions. I don't know what else to do but to ask them. I will use separate posts.

The default page is public/index.html. Presumable this would be what one would use as a home page. I don't understand why it's setup as an html page (rather than an rhtml page). I would think that it would be a common requirement to have embedded ruby code in the home page. Presumably I'm either missing something or there is an easy work around. Could someone please square me away? Thanks.

        ... doug

Hi Doug,

The default page is public/index.html. Presumable this would be what one would use as a home page. I don't understand why it's setup as an html page (rather than an rhtml page). I would think that it would be a common requirement to have embedded ruby code in the home page.

Only pages within the application space get processed via Rails and thus have their eRb processed into html. The /public directory in which all browsers look for index.html is not within the Rails application space. You can override this. Tom Fakes posted the following recently in response to a similar query.

I usually have a controller I call 'main', with an action called 'index' for my home page. Then I have a named route:

map.home '/', :controller => 'main', :action => 'index'

I can add my About, Terms and Conditions, and other random pages that don't fit anywhere else in the main controller.

hth, Bill

Everything under the public directory such as static html pages, images, javascripts and stylesheets will be served up to the browser by the webserver. It is there as a static file so that you can verify that you have installed everything properly on your machine. When you run the script/server on your machine, you will see the Welcome aboard, You are riding on Rails welcome screen. You can click on the environment setup which uses AJAX calls to show details about your environment. My environment setup looks like this:

Ruby version 1.8.5 (powerpc-darwin8.8.0) RubyGems version 0.9.2 Rails version 1.2.2 Active Record version 1.15.2 Action Pack version 1.13.2 Action Web Service version 1.2.2 Action Mailer version 1.3.2 Active Support version 1.4.1 Application root /Users/balaparanj/work/my_app Environment development Database adapter mysql

doug wrote:

Hi --

I'm very new to rails. I have a couple of what have to be very naive questions. I don't know what else to do but to ask them. I will use separate posts.

The default page is public/index.html. Presumable this would be what one would use as a home page. I don't understand why it's setup as an html page (rather than an rhtml page). I would think that it would be a common requirement to have embedded ruby code in the home page. Presumably I'm either missing something or there is an easy work around. Could someone please square me away? Thanks.

To render an .rhtml page requires the presense of a controller and a default "/" route pointing to that controller, neither of which are present when you run "rails <myapp>". That is why it's a static HTML page.

> I usually have a controller I call 'main', with an action called > 'index' for my home page. Then I have a named route:

> map.home '/', :controller => 'main', :action => 'index'

Works great. They also have an example of how to do it using a regular route (as opposed to a named route) in routes.rb. In both cases one has to remember to trash public/index.html for the routing to work. Thanks for the input.

      ... doug