Kambinja
Kambinja

Reputation: 1

Why does Localhost:3000 points to default page?

I'm new to Rails. With rails running, opening localhost:3000 takes me to default "welcome aboard" page. Rake routes command puts out a message that I don't have any routes defined, but I didn't change anything in config/routes.rb.

I tried to download back my github repository, but the problem persists. Any idea, please?

@MarcinAdamczyk, @RichPeck. I should say that localhost did work before. this is what I have:

1) Pinteresting::Application.routes.draw do resources :pins

devise_for :users
devise_for :installs
root "pages#home"
get "about" => "pages#about"  

2) class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception end

def home end

3) class PagesController < ApplicationController def home end

def about

end end

Upvotes: 0

Views: 2029

Answers (2)

Richard Peck
Richard Peck

Reputation: 76774

Routes

You'll need to change your routes to have the following:

#config/routes.rb
root "application#index"

You can then create & corresponding controller action:

#app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
   def index
   end
end

#app/views/application/index.html.erb
Test

This should fix your immediate issue, judging from what you've posted.

Upvotes: 0

Marcin Adamczyk
Marcin Adamczyk

Reputation: 509

If you are using Rails <4 then you need to remove index.html from public folder and set root to: 'controller#method' in config/routes.rb

If its Rails 4 then only setting root route should be enough.

Upvotes: 3

Related Questions