ruby - Method undefined for modules in rails 4? -
file structure:
../controllers /api /v1 users_controller.rb some_controller.rb
inside users_controller.rb
module api module v1 class userscontroller < applicationcontroller def create return false end end end end
i can include api in controller , api::v1::userscontroller. however, when try
api::v1::userscontroller.create
in controller error:
undefined method `create' api::v1::userscontroller:class
i've tried doing modules in lib, rails 4 autoloading being weird tried doing way, don't know why methods undefined. when go console , puts api::v1::userscontroller.methods.sort, :create method isn't there. doing wrong?
create
not class method. can't called class.method
.
you need instance of class call it.
if want try(though not way controller work)
api::v1::userscontroller.new.create
Comments
Post a Comment