No route matches [GET] "/ app1"
Rails.root: / home / chris / rails_projects / app1
I am getting a message about the routes. my route.rb files show:
I don't know how to approach this at all. I am using Ubuntu 12.04 in Virtualbox.
Rails.application.routes.draw do
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
# root 'welcome#index'
# Example of regular route:
# get 'products/:id' => 'catalog#view'
# Example of named route that can be invoked with purchase_url(id: product.id)
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
# Example resource route (maps HTTP verbs to controller actions automatically):
# resources :products
# Example resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end
# Example resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end
# Example resource route with more complex sub-resources:
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', on: :collection
# end
# end
# Example resource route with concerns:
# concern :toggleable do
# post 'toggle'
# end
# resources :posts, concerns: :toggleable
# resources :photos, concerns: :toggleable
# Example resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
end
source to share
You need to create a controller and a view to point your application somewhere.
Then you need to direct your application to this action by editing the routes file. For example, you can uncomment the line:
root 'welcome#index'
This means that when you navigate to the root of your site in the root directory (/ app1), it will navigate to the welcome controller for its index action.
To find out more take a look: http://guides.rubyonrails.org/routing.html#using-root
source to share
You need to define routes that will be used by your application:
#config/routes.rb
root 'application#index'
This will route any of the "initial" traffic to the next controller / action:
#app/controllers/application_controller.rb
Class ApplicationController < ActionController::Base
def index
end
end
-
Rails routing
You must remember that Rails is an MVC- centric web application framework.
This means that every time you want to access "url", you need to define a "route" in your file routes.rb
. The way to do this is to reference the appropriate one controller#actions
in your routes file - with the method resources
:
#config/routes.rb
root "application#index"
resources :controller_1, :controller_2
Because Rails is object-oriented , routes
your application generally needs to reflect the various resources it has internally. Most people try to define routes based on the intended "flow" of the application - the truth is that you want to build them around objects, which usually means controller and / or models
source to share