when I include module in controller, the routing is not work, report 404 not found error, below is my code, very sample
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
module/class
name should start with capital letter Common
module Common
class A; end
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.