[英]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.