我有我保存常量关注中:Rails的:包括以恒定的一个值得关注的一个关注
module Group::Constants
extend ActiveSupport::Concern
MEMBERSHIP_STATUSES = %w(accepted invited requested
rejected_by_group rejected_group)
end
而且我希望使用这些常量另一个问题:不幸的是
module User::Groupable
extend ActiveSupport::Concern
include Group::Constants
MEMBERSHIP_STATUSES.each do |status_name|
define_method "#{status_name}_groups" do
groups.where(:user_memberships => {:status => status_name})
end
end
end
,这会导致路由错误:
uninitialized constant User::Groupable::MEMBERSHIP_STATUSES
它看起来像第一关心的是不正确加载第二个问题。如果是这样的话,我能做些什么呢?
你打电话来得到这个错误的代码是什么?或者当'User :: Groupable'模块被加载时发生? – PinnyM 2013-04-11 16:18:16
加载'User :: Groupable'时发生。 – nullnullnull 2013-04-11 16:20:59