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

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -