diff --git a/app/models/concerns/proposable.rb b/app/models/concerns/proposable.rb new file mode 100644 index 0000000..aa79043 --- /dev/null +++ b/app/models/concerns/proposable.rb @@ -0,0 +1,11 @@ +module Proposable + extend ActiveSupport::Concern + + included do + has_one :proposition, as: :proposable + + Proposition.defined_enums["status"].keys.each do |status| + scope status.to_sym, -> { joins(:proposition).where(propositions: {status: Proposition.defined_enums["status"][status]}) } + end + end +end