Topic: Ruby on Rails- Setting the Application Home Page


I'm following the tutorial at:

and I've got to step 4.3 Setting the Application Home Page- I've deleted the default page from my application as it said, and edited the config/ routes.rb file as indicated.

It then says that if you browse to http://localhost:3000 in your browser, you'll see "Hello Rails!", however, I'm getting an "Unable to connect" page being displayed.... I was just wondering if anyone knows why this is?

If I view the page by typing in its location, i.e. file:///D:Users/....index.html.erb, I get a page displaying "Hello Rails!".

Is it possible that some settings aren't correctly configured on my computer? Or is there something else I need to do to be able to view the page from my localhost... maybe permissions? In which case, is there any easy way to set those on a Windows machine? I've only ever done that on Unix before...

Re: Ruby on Rails- Setting the Application Home Page

Ok, I've tried altering a few little things, and I'm now getting an 'Action Controller: Exception caught' page when I browse to localhost:3000, which displays a routing error that says:    no route matches"/"

Does anyone know why I'm not getting my "Hello Rails" page?

Re: Ruby on Rails- Setting the Application Home Page

You don't have a rote configured for the root url
If you look in your routes.rb file you should see a commented out root url.
It will look something like this

  # root :to => 'welcome#index'

Uncomment that route and set the path to be whatever controller/action parining you want it to be
i.e. if you wanted the main landing page for your site to be the users index.html.erb file then you would set it to

   root :to => 'users#index'

Hope that helps

p.s. this will only work if (as you have already indicated that you have done so) you remove the index.html file from the public folder of your app

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)

Re: Ruby on Rails- Setting the Application Home Page

There are two functions current_user_session and current_user. here , curent_user function is using current_user_session and current_user_session is using current_account function. So could you please understand me the working of these functions and also what current_user_session is returning ?  I am totally a newbie in this rails development

def current_user_session
    return @current_user_session if defined?(@current_user_session)
    @current_user_session = current_account.user_sessions.find

def current_user
    return @current_user if defined?(@current_user)
    @current_user = current_user_session && current_user_session.user

thanks in advance

Last edited by ankitagarwal (2012-08-31 04:07:53)