Public/index.html


#1

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

#2

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


#3

doug wrote:

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 ". That is why it’s a static HTML
page.


Michael W.


#4

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 version1.8.5 (powerpc-darwin8.8.0)RubyGems version0.9.2Rails
version
1.2.2Active Record version1.15.2Action Pack version1.13.2Action Web
Service
version1.2.2Action Mailer version1.3.2Active Support
version1.4.1Application
root/Users/balaparanj/work/my_appEnvironmentdevelopmentDatabase
adaptermysql


#5

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