Ruby on rails 没有与[GET]匹配的路由/附录1“;

Ruby on rails 没有与[GET]匹配的路由/附录1“;,ruby-on-rails,ubuntu,get,routes,Ruby On Rails,Ubuntu,Get,Routes,Rails.root:/home/chris/Rails\u projects/app1 我得到了关于路线的信息。my routes.rb文件显示: 我根本不知道如何处理这个问题。我正在Virtualbox中使用Ubuntu12.04 Rails.application.routes.draw do # The priority is based upon order of creation: first created -> highest priority. # See how

Rails.root:/home/chris/Rails\u projects/app1

我得到了关于路线的信息。my routes.rb文件显示:

我根本不知道如何处理这个问题。我正在Virtualbox中使用Ubuntu12.04

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

你需要创建一个控制器和一个视图来引导你的应用程序

然后,您需要通过编辑路由文件将应用程序路由到该操作。例如,您可以取消对行的注释:

 root 'welcome#index'
这将意味着当您在根目录(/app1)中导航到站点的根目录时,将转到欢迎控制器的索引操作

要了解更多信息,请查看:

您需要定义应用程序将使用的路由,如下所示:

#config/routes.rb
root 'application#index'
这将引导任何“主页”流量到以下控制器/操作:

#app/controllers/application_controller.rb
Class ApplicationController < ActionController::Base
   def index
   end
end

与Rails一样,应用程序的
路由
通常必须反映其内部的各种资源。大多数人试图根据应用程序的假定“流”来定义路由-事实上,您希望围绕对象构建路由,这通常意味着控制器和/或模型

错误是
没有与[GET]匹配的路由“/app1”
因此,在新应用程序中,这与根路由无关。如果您没有任何根路由,那么rails 4有默认的根路由,checkout:)
#config/routes.rb
root "application#index"
resources :controller_1, :controller_2