Missing region scope

This commit is contained in:
echarp 2018-03-18 16:05:26 +01:00
parent 3e044ca64a
commit 2ee90cd937

View File

@ -6,6 +6,11 @@ class Region < ApplicationRecord
has_many :orgas, dependent: :destroy
default_scope { order :name }
scope :region, (lambda do |region|
return if region.nil? || region == 'all' || region.to_i.zero?
temp = Region.find region
where region: [temp, temp.regions].flatten
end)
def to_s
name