定数を格納する懸念があります。
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
最初の懸念事項が 2 番目の懸念事項に適切に読み込まれていないようです。その場合、どうすればよいですか?