Sha256: eb80a2a7521d1ccc8b6ce11ec827eaf43147452bf5289b689b0e5dd0dc407c2f
Contents?: true
Size: 709 Bytes
Versions: 7
Compression:
Stored size: 709 Bytes
Contents
module EveApp::ActivityRelation extend ActiveSupport::Concern included do belongs_to :type belongs_to :activity # scope :invention, -> { where(activity_id: EveApp::Activity::INVENTION) } scope :for, -> (tid, aid) { where(type_id: tid, activity_id: aid) } scope :order_by_name, -> { includes(type_name).order('types.name') } # ???? # def activity_activity # EveApp::Activity.where(type_id: type_id, activity_id: activity_id) # end end class_methods do def type_name reflections = self.reflect_on_all_associations(:belongs_to) reflections.select { |r| r.options[:class_name] == 'Type' && r.name != :type }.first.name end end end
Version data entries
7 entries across 7 versions & 1 rubygems