#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Posts
    13
    Rep 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?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Posts
    83
    Rep Power
    39
    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?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Posts
    13
    Rep Power
    0
    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 "/"
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Posts
    13
    Rep Power
    0
    The tutorial says that

    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...

IMN logo majestic logo threadwatch logo seochat tools logo