我在设置视图时遇到了大问题..每当我进入我的页面 localhost/clear 我都会得到
No route matches [GET] "/clear".
我的控制器中有一个名为 clear 的文件夹,其中包含控制器文件。
我如何将其设置为:
localhost/clear as main view,
and other one as
localhost/clear/connect
localhost/clear/test
base_controller.rb
class Clear::BaseController < ApplicationController
def index
end
end
connect_controller.rb
class Clear::ConnectController< Clear::BaseController
def index
@functions
end
end
routes.rb
resources :clear, only: :index
namespace :clear do
resources :connect, only: :index
resources :test, only: :index
end
答案 0 :(得分:1)
您错过了 /clear
的路线
# routes.rb
namespace :clear do
resources :base, only: :index, path: '/'
resources :connect, only: :index
resources :test, only: :index
end
这是如何检查你有哪些路线
rake routes | grep clear
# =>
clear_base_index GET /clear(.:format) clear/base#index
clear_connect_index GET /clear/connect(.:format) clear/connect#index
clear_test_index GET /clear/test(.:format) clear/test#ind