Ruby: importing two modules/classes of the same name -
when system requires 2 classes or modules of same name, can specify mean?
i'm using rails (new it), , 1 of models named "thread". when try refer class "thread" in thread_controller.rb, system returns other constant of same name.
<thread.rb> class thread < activerecord::base def self.some_class_method end end <thread_controller.rb> class threadcontroller < applicationcontroller def index require '../models/thread.rb' @threads = thread.find :all end end
when try thread.find(), error saying thread has no method named find. when access thread.methods, don't find some_class_method method among them.
any help? (and don't bother posting "just name model else." it's not helpful point out obvious compromises.)
you put app own namespace.
<my_app/thread.rb> module myapp class thread end end
Comments
Post a Comment