[英]rails route error when include module in controller
當我在控制器中包含模塊時,路由不起作用,報告404未找到錯誤,以下是我的代碼,非常示例
紅寶石:2.0,軌道:4.2.3
routes.rb
match ':controller(/:action(/:id))', via: :all
common.rb
module Common
class A; end
end
test_controller.rb
class TestController < ApplicationController
include Common # when I delete this line , this route '/test/hello' works as expected,
# otherwise rails reports 404 not found
def hello
render :json => {msg: 'hello'}
end
end
module/class
名應以大寫字母開頭Common
module Common
class A; end
end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.