Ruby Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesRuby Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 4th, 2012, 08:32 AM
someone2088 someone2088 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2012
Posts: 13 someone2088 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 54 m 16 sec
Reputation Power: 0
Ruby on Rails tutorial

Hi, I'm following the tutorial at:

guides.rubyonrails.org/getting_started.html

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 'Action Controller: Exception caught' page when I browse to localhost:3000, which displays a routing error that says: no route matches"/"

Does anyone know what I'm doing wrong here, and how I can correct it?

Reply With Quote
  #2  
Old August 4th, 2012, 02:02 PM
sepp2k1 sepp2k1 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2012
Posts: 75 sepp2k1 User rank is Sergeant Major (2000 - 5000 Reputation Level)sepp2k1 User rank is Sergeant Major (2000 - 5000 Reputation Level)sepp2k1 User rank is Sergeant Major (2000 - 5000 Reputation Level)sepp2k1 User rank is Sergeant Major (2000 - 5000 Reputation Level)sepp2k1 User rank is Sergeant Major (2000 - 5000 Reputation Level)sepp2k1 User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Day 23 h 20 m 52 sec
Reputation Power: 38
Quote:
Originally Posted by someone2088
and edited the config/ routes.rb file as indicated.


My guess is that your problem lies here. Can you post your changed routes.rb?

Reply With Quote
  #3  
Old August 6th, 2012, 09:16 AM
someone2088 someone2088 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2012
Posts: 13 someone2088 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 54 m 16 sec
Reputation Power: 0
Quote:
Originally Posted by sepp2k1
My guess is that your problem lies here. Can you post your changed routes.rb?


My routes.rb file now looks like this:

Code:
Csa::Application.routes.draw do
  resources :users do
  	collection do
  		get 'search'
  		get 'search_dropdown'
  	end
  end
  
  resources :broadcasts
  
  # A singleton resource and so no paths requiring ids are generated
  # Also, don't want to support editing of the session
  resource :session, :only => [:new, :create, :destroy]
  
  match 'home' => 'home#index', :as => :home
  match 'users/:id' => 'users#show', :as => :profile

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

  # Sample of regular route:
  #   match 'products/:id' => 'catalog#view'
  # Keep in mind you can assign values other than :controller and :action

  # Sample of named route:
  #   match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
  # This route can be invoked with purchase_url(:id => product.id)

  # Sample resource route (maps HTTP verbs to controller actions automatically):
  #   resources :products

  # Sample resource route with options:
  #   resources :products do
  #     member do
  #       get 'short'
  #       post 'toggle'
  #     end
  #
  #     collection do
  #       get 'sold'
  #     end
  #   end

  # Sample resource route with sub-resources:
  #   resources :products do
  #     resources :comments, :sales
  #     resource :seller
  #   end

  # Sample resource route with more complex sub-resources
  #   resources :products do
  #     resources :comments
  #     resources :sales do
  #       get 'recent', :on => :collection
  #     end
  #   end

  # Sample resource route within a namespace:
  #   namespace :admin do
  #     # Directs /admin/products/* to Admin::ProductsController
  #     # (app/controllers/admin/products_controller.rb)
  #     resources :products
  #   end

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

  # See how all your routes lay out with "rake routes"

  # This is a legacy wild controller route that's not recommended for RESTful applications.
  # Note: This route will make all actions in every controller accessible via GET requests.
  # match ':controller(/:action(/:id(.:format)))'
end


The only change I've made is that I've uncommented the line:

Code:
root :to => "home#index"


The tutorial says that once you've done that, if you navigate to http://localhost:3000 in your browser, you'll see "Hello Rails", but for some reason, I'm getting 'Action Controller: Exception caught' which says: Routing Error no route matches "/"

Reply With Quote
  #4  
Old August 6th, 2012, 11:19 AM
someone2088 someone2088 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2012
Posts: 13 someone2088 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 54 m 16 sec
Reputation Power: 0
The tutorial says that

Quote:
The root :to => "home#index" tells Rails to map the root action to the home controller’s index action.


So to get my home page displayed in a browser, do I need to change the home controller's index action to my home page's filepath? If so, how would I do this? I can't see any files or folders called controller in the directory...

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesRuby Programming > Ruby on Rails tutorial

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap