Kirinriki
Kirinriki

Reputation: 875

Rails 3 - changing index

I'm using Rails 3 and have the feeling that the syntax for changing the route for the index (http://localhost:3000) is different than from the former versions.

I'd like to open the dynamic index page (index.html.erb) of the employees-controller (which can be right now opened with localhost:3000/employees) as the default page (localhost:3000). I thought it's quite easy, because in the routes it's written:

  # You can have the root of your site routed with "root"
  # just remember to delete public/index.html.
  # root :to => "welcome#index"

So that's what I actually did: I deleted public/index.html and set root :to => "employees#index". But when I open the server and open localhost:3000, it's still opening the "welcome abroad!"-page. Pretty weird!

So I googled the problem and found answers which said, I should write this into my routes-file:

map.root :controller => 'employees', :action => 'index'

Same here - I also still get the "welcome abroad!"-page and the rails-shell says "undefined local variable or method 'map'". (I think this is the old syntax for Rails 2...?)

match "/" => "employees#index" says routing error: No route matches "/"

So what did I do wrong? How can I solve this problem?

Upvotes: 1

Views: 1232

Answers (2)

Dnyan Waychal
Dnyan Waychal

Reputation: 1418

I think problem is of cookies. please clear the cookies and the refresh the page.

Upvotes: 0

socjopata
socjopata

Reputation: 5095

Why you use "map" in Rails 3? Should be:

   root :to => "employees#index"

Upvotes: 0

Related Questions