controller 路径 /app/controllers/amount/amount_controller
#routes.rb
devise_for :users
root to: "home#index"
namespace :amount do
match '/', to: 'amount#index', via: 'get'
end
#/app/controllers/amount/amount_controller.rb
class AmountController < ApplicationController
def index
debugger
@user=current_user
end
end
`rake routes`
# root GET / home#index
# amount GET /amount(.:format) amount/amount#index
然后请求http://0.0.0.0:3000/amount
,出现Unable to autoload constant Amount::AmountController, expected /home/fan/rails/Bank/app/controllers/amount/amount_controller.rb to define it
, 刷新后是这个错误Circular dependency detected while autoloading constant Amount::AmountController
如何解决?还有请问子目录下面的 controller 要怎么指定路由?使用namespace
?
谢谢