Introduce a Proposable concern

The Proposable concern defines a relation to a Proposition and defines
scopes that translate to the statuses of the Proposition.
This commit is contained in:
Petko Bordjukov 2015-04-20 18:35:22 +03:00
parent d6e3f9ba5d
commit 8508d64a92
1 changed files with 11 additions and 0 deletions

View File

@ -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