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:
parent
d6e3f9ba5d
commit
8508d64a92
|
@ -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
|
Loading…
Reference in New Issue