当我在控制器中包含模块时,路由不起作用,报告404未找到错误,下面是我的代码,非常样本
ruby:2.0,rails: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
答案 0 :(得分:0)
module/class
名称应以大写字母Common
module Common
class A; end
end