我不知道我在做什么错在这里,我有一个文件在lib/acts_as_votable.rb
,它只是一个投票系统的应用程序。正确加载Rails的红宝石模块
module ActsAsVotable
end
module ActiveRecord
class Base
class << self
cattr_accessor :votable
def acts_as_votable
has_many :votes, :as => :voteable
end
def votable?
method_defined? :votes
end
end
def votable?
self.class.send(:method_defined?, :votes)
end
end
end
但似乎从来没有模块加载:
undefined local variable or method `acts_as_votable' for #<Class:0x00000101796d80>
会是怎样加载模块的正确方法?
您正在使用哪种rails版本? – 2010-08-23 08:54:11
我正在运行1.9.2-head – 2010-08-23 15:35:32
据我所知,Rails 3不会从'lib'预装文件。 – 2010-08-23 16:01:52