app/models/unidom/common/concerns/model_extension.rb in unidom-common-0.8 vs app/models/unidom/common/concerns/model_extension.rb in unidom-common-0.9
- old
+ new
@@ -24,9 +24,13 @@
scope :notation_column_where, ->(name, operator, value) do
operation = :like==operator ? { operator: 'ILIKE', value: "%#{value}%" } : { operator: operator.to_s, value: value }
where "#{table_name}.notation -> 'columns' ->> '#{name}' #{operation[:operator]} :value", value: operation[:value]
end
+ scope :notation_boolean_column_where, ->(name, value) do
+ where "(#{table_name}.notation -> 'columns' ->> '#{name}')::boolean = :value", value: (value ? true : false)
+ end
+
if columns_hash['ordinal'].present?
validates :ordinal, presence: true, numericality: { integer_only: true, greater_than: 0 }
scope :ordinal_is, ->(ordinal) { where ordinal: ordinal }
end
\ No newline at end of file