Forum: Ruby on Rails Very Noob Question: 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.
63869e6379cc0beb50b7514cb73bda18?d=identicon&s=25 Newby (Guest)
on 2007-06-06 23:22
Hi,

I have a very noob question. I just started on RoR this week, glad to be
on board. I'm just wondering where I edit the first page when people
come to the site, index.html. There seems to be one in the public
folder. However, how do I make that a dynamic page?

Thanks
7b25be2f2b6c5d0a9cae484009a9109f?d=identicon&s=25 James Mitchell (Guest)
on 2007-06-06 23:27
(Received via mailing list)
Rename or remove that file and add a default route.

Look in your routes.rb file.  You'll see something like this...


   # You can have the root of your site routed by hooking up ''
   # -- just remember to delete public/index.html.
   # map.connect '', :controller => "index"


Uncomment that and generate an index controller or whatever name you
like.


--
James Mitchell
1fba4539b6cafe2e60a2916fa184fc2f?d=identicon&s=25 unknown (Guest)
on 2007-06-06 23:42
(Received via mailing list)
Hi --

On Wed, 6 Jun 2007, Newby wrote:

>
> Hi,
>
> I have a very noob question. I just started on RoR this week, glad to be
> on board.

Welcome!

> I'm just wondering where I edit the first page when people
> come to the site, index.html. There seems to be one in the public
> folder. However, how do I make that a dynamic page?

Rails uses its routing system to figure out what to do given a
particular URL.  That applies even when the URL is empty: you have to
register a routing rule that says what to do in response to the empty
URL.

To do this, look inside the file config/routes.rb.  You'll see a
section like this:

   # You can have the root of your site routed by hooking up ''
   # -- just remember to delete public/index.html.
   # map.connect '', :controller => "welcome"

You want to uncomment the third line, and customize it to correspond
to whatever controller/action combo you want triggered by the empty
URL.  (The action defaults to "index", so the example above triggers
the index action of the welcome controller.)

So a typical case might look like:

   map.connect '', :controller => "main", :action => "top"

or

   map.connect '', :controller => "main"    # default to "index" action

etc.

And, like it says, don't forget to delete public/index.html :-)


David

--
Q. What is THE Ruby book for Rails developers?
A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black)
    (See what readers are saying!  http://www.rubypal.com/r4rrevs.pdf)
Q. Where can I get Ruby/Rails on-site training, consulting, coaching?
A. Ruby Power and Light, LLC (http://www.rubypal.com)
588ab1c0a5610a7e160a3b101abb91e6?d=identicon&s=25 MichaelLatta (Guest)
on 2007-06-06 23:50
(Received via mailing list)
The index.html that is in public is just a place holder.  Delete that
file and add a route in routes.rb for the "/" path to point to a
controller and action you want for the default content.

I recommend getting "Agile Web Development with Rails" which starts
with a short and to the point tutorial that gets an application up and
running, then dives into more detail on each component of an
application.

Michael
This topic is locked and can not be replied to.