【发布时间】:2016-02-18 22:54:39
【问题描述】:
我有 1 个班级和 1 个模块:
约会.rb
class Appointment < ActiveRecord::Base
include Appointments::Events
ALERT = "hello!"
end
events.rb
module Appointments
module Events
extend ActiveSupport::Concern
def say_alert
puts self.class::ALERT
end
end
end
调用 #say_alert 给我:
uninitialized constant Module::ALERT
【问题讨论】:
-
不知道 ruby,但它似乎无法找到 ALERT 是什么,可能是范围问题