Forum: Ruby on Rails public/index.html

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.
80159acdf89580a20e8e835772b5bf82?d=identicon&s=25 doug (Guest)
on 2007-03-10 18:51
(Received via mailing list)
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
2b891e820c238ded365d035771603f21?d=identicon&s=25 Bill Walton (Guest)
on 2007-03-10 20:03
(Received via mailing list)
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
E3640176765dae2465d33ef6eb114691?d=identicon&s=25 Bala Paranj (Guest)
on 2007-03-10 22:29
(Received via mailing list)
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
Dfd6f9989147955682701da8227df8b4?d=identicon&s=25 Michael Wang (Guest)
on 2007-03-11 02:58
(Received via mailing list)
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 <myapp>". That is why it's a static HTML
page.


--
Michael Wang
80159acdf89580a20e8e835772b5bf82?d=identicon&s=25 doug (Guest)
on 2007-03-11 23:21
(Received via mailing list)
> > 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
This topic is locked and can not be replied to.