# Rails not rerouting to new page

**URL:** <https://www.ruby-forum.com/t/rails-not-rerouting-to-new-page/194077>\
**Category:** Rails\
**Created:** [August 29, 2010, 11:26pm UTC](https://www.ruby-forum.com/t/rails-not-rerouting-to-new-page/194077 "2010-08-29T23:26:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [August 29, 2010, 11:26pm UTC](https://www.ruby-forum.com/t/rails-not-rerouting-to-new-page/194077/1 "2010-08-29T23:26:57Z")

</div>

i am running virtual rails on linux mint. i created a controller in  
my commnad prompt. then i opened up the public folder and delted  
index.html … after this I opened up the rails application i created  
and went to config / routes.rb. I am trying to re route or add a new  
route to the default page. I have pasted the code below.

I tried editing the line  
map.root :controller =\> “welcome” and i changed welcome to “site”  
but it didnt re route…Can someone please tell me which line to  
edit and what to put in the line?

ActionController::Routing::Routes.draw do |map|

# The priority is based upon order of creation: first created -\>

highest priority.

# Sample of regular route:

# map.connect ‘products/:id’, :controller =\> ‘catalog’, :action =\>

‘view’

# Keep in mind you can assign values other than :controller

and :action

# Sample of named route:

# map.purchase ‘products/:id/purchase’, :controller =\>

‘catalog’, :action =\> ‘purchase’

# This route can be invoked with purchase\_url(:id =\> product.id)

# Sample resource route (maps HTTP verbs to controller actions

automatically):

# map.resources :products

# Sample resource route with options:

# map.resources :products, :member =\> { :short =\> :get, :toggle

=\> :post }, :collection =\> { :sold =\> :get }

# Sample resource route with sub-resources:

# map.resources :products, :has\_many =\>

[:comments, :sales], :has\_one =\> :seller

# Sample resource route with more complex sub-resources

# map.resources :products do |products|

# products.resources :comments

# products.resources :sales, :collection =\> { :recent =\> :get }

# end

# Sample resource route within a namespace:

# map.namespace :admin do |admin|

# # Directs /admin/products/\* to Admin::ProductsController (app/

controllers/admin/products\_controller.rb)

# admin.resources :products

# end

# You can have the root of your site routed with map.root – just

remember to delete public/index.html.  
map.root :controller =\> “welcome”

# See how all your routes lay out with “rake routes”

# Install the default routes as the lowest priority.

# Note: These default routes make all actions in every controller

accessible via GET requests. You should

# consider removing or commenting them out if you’re using named

routes and resources.  
map.connect ‘:controller/:action/:id’  
map.connect ‘:controller/:action/:id.:format’  
end

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [August 30, 2010, 9:36am UTC](https://www.ruby-forum.com/t/rails-not-rerouting-to-new-page/194077/2 "2010-08-30T09:36:17Z")

</div>

On 29 August 2010 22:13, Rich d [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> # map.resources :products, :member =\> { :short =\> :get, :toggle
> 
> # end
> 
> map.root :controller =\> “welcome”  
> You have not changed this line. Change welcome to the name of your  
> controller.

Assuming you have done this and it still does not work then show us  
the error when you go to [http://localhost:3000/](http://localhost:3000/)

In fact you might be best first to have a look at the Getting Started  
guide at [http://guides.rubyonrails.org/](http://guides.rubyonrails.org/) and for routes in particular  
you will find one on that also. In fact look at them all.

Colin

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [September 2, 2010, 12:28am UTC](https://www.ruby-forum.com/t/rails-not-rerouting-to-new-page/194077/3 "2010-09-02T00:28:27Z")

</div>

running virtual rails on linux mint with rails 2.3.4

im having trouble redirecting routes so here is what ive done by  
following tutorials:

i opened rails directory and created rails\_test  
then i ran script/server to boot mongrel  
i opened another terminal and changed directory to rails\_test  
i then ran script/generate controller site index about help  
then i went back to terminal and typed rm public/index.html to remove  
index page  
after this i went to rails\_test folder then navigated and opened  
config routes.rb  
once in routes.rb i changed the following line:

map.root :controller =\> “welcome” to…  
map.root :controller =\> “site”

i then got an error message stating something went wrong after opening  
browser and navigating to [http://localhost:3000/](http://localhost:3000/)  
i have pasted below the routes.rb file  
the only thing i changed was  
map.root :controller =\> “welcome” to…  
map.root :controller =\> “site”

ActionController::Routing::Routes.draw do |map|

# The priority is based upon order of creation: first created →

highest priority.

# Sample of regular route:

# map.connect ‘products/:id’, :controller =\> ‘catalog’, :action =\>

‘view’

# Keep in mind you can assign values other than :controller

and :action

# Sample of named route:

# map.purchase ‘products/:id/purchase’, :controller =\>

‘catalog’, :action =\> ‘purchase’

# This route can be invoked with purchase\_url(:id =\> product.id)

# Sample resource route (maps HTTP verbs to controller actions

automatically):

# map.resources :products

# Sample resource route with options:

# map.resources :products, :member =\> { :short =\> :get, :toggle

=\> :post }, :collection =\> { :sold =\> :get }

# Sample resource route with sub-resources:

# map.resources :products, :has\_many =\>

[:comments, :sales], :has\_one =\> :seller

# Sample resource route with more complex sub-resources

# map.resources :products do |products|

# products.resources :comments

# products.resources :sales, :collection =\> { :recent =\> :get }

# end

# Sample resource route within a namespace:

# map.namespace :admin do |admin|

# # Directs /admin/products/\* to Admin::ProductsController (app/

controllers/admin/products\_controller.rb)

# admin.resources :products

# end

# You can have the root of your site routed with map.root – just

remember to delete public/index.html.  
map.root :controller =\> “site”

# See how all your routes lay out with “rake routes”

# Install the default routes as the lowest priority.

# Note: These default routes make all actions in every controller

accessible via GET requests. You should

# consider removing or commenting them out if you’re using named

routes and resources.  
map.connect ‘:controller/:action/:id’  
map.connect ‘:controller/:action/:id.:format’  
end

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [September 2, 2010, 10:16pm UTC](https://www.ruby-forum.com/t/rails-not-rerouting-to-new-page/194077/4 "2010-09-02T22:16:22Z")

</div>

Thank you Colin. I believe you may be correct about the logfile. I  
did change the name of the controller so it must be something else. I  
will follow what you suggested and get back to you if I still havent  
solved the problem. I replied in a different section so I hope this  
prevented the top posting you mentioned…

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [September 2, 2010, 9:36am UTC](https://www.ruby-forum.com/t/rails-not-rerouting-to-new-page/194077/5 "2010-09-02T09:36:20Z")

</div>

On 1 September 2010 23:21, Rich d [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> index page  
> after this i went to rails\_test folder then navigated and opened  
> config routes.rb  
> once in routes.rb i changed the following line:
> 
> map.root :controller =\> “welcome” to…  
> map.root :controller =\> “site”
> 
> i then got an error message stating something went wrong after opening  
> browser and navigating to [http://localhost:3000/](http://localhost:3000/)

Have you looked in the log file (log/development.log assuming you are  
running in development mode), there may well be more information  
there. I think I have already suggested that but you have not said  
what you found. Also look in the window where you started the server  
running (presumably you did start the server though you did not  
mention this), there may be more there.

My best guess is that you have not setup the database correctly in  
database.yml. That should be clear from the log however.

Also please do not top post, insert your reply into the previous  
message. Thanks

Colin
