gpt4 book ai didi

ruby-on-rails - 没有路由匹配 [GET] "/app1"

转载 作者:太空宇宙 更新时间:2023-11-03 16:58:13 24 4
gpt4 key购买 nike

Rails.root:/home/chris/rails_projects/app1

我收到有关路线的消息。我的 routes.rb 文件显示:

我完全不知道如何处理这个问题。我在 Virtualbox 中使用 Ubuntu 12.04。

Rails.application.routes.draw 做

  # 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

最佳答案

您需要创建一个 Controller 和一个 View 来将您的应用定向到某个地方。

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

 root 'welcome#index'

这将意味着当您导航到位于根目录 (/app1) 的站点根目录时,将转到欢迎 Controller 及其索引操作。

要了解更多信息,请查看:http://guides.rubyonrails.org/routing.html#using-root

关于ruby-on-rails - 没有路由匹配 [GET] "/app1",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25225878/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com