我在設定視圖時遇到了大問題.. 每當我進入我的頁面 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
連接控制器.rb
class Clear::ConnectController< Clear::BaseController
def index
@functions
end
end
路線.rb
resources :clear, only: :index
namespace :clear do
resources :connect, only: :index
resources :test, only: :index
end
uj5u.com熱心網友回復:
你錯過了路線 /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
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/416230.html
標籤:
