我在文件LIB的方法/我的/ column.rb如何包括我自己在軌方法
module Column
def array_each_col(num_of_cols, array_arg)
.. code will return array ..
end
end
我希望在我的模型
class Area < ActiveRecord::Base
include Column
def self.my_areas
all_areas = Area.all
num_of_cols = 2
self.array_each_col(num_of_cols, all_areas)
end
end
我的應用程序中使用它。 RB
module MyAppName
class Application < Rails::Application
config.autoload_paths << "#{config.root}/lib/my"
但它不工作
我會用我的方法不同模型 – user1466717
「不起作用」不是任何有效的描述。你期望發生什麼,你觀察到了什麼?你有什麼努力去匹配兩者?基本上http://whathaveyoutried.com –
未定義的方法'array_each_col'爲# –
user1466717