Region selector and filter better scoped
This commit is contained in:
parent
b617ee1dca
commit
61e67072c0
@ -6,7 +6,8 @@ class Region < ApplicationRecord
|
|||||||
has_many :orgas, dependent: :destroy
|
has_many :orgas, dependent: :destroy
|
||||||
|
|
||||||
default_scope { order :name }
|
default_scope { order :name }
|
||||||
scope :local, ->(*) { where 'url IS NULL OR url = \'\'' }
|
scope :top, ->(*) { where(region: nil).includes(:regions).reorder :code }
|
||||||
|
scope :local, ->(*) { where(url: nil).or(Region.where(url: '')) }
|
||||||
scope :region, (lambda do |region|
|
scope :region, (lambda do |region|
|
||||||
return if region.nil? || region == 'all' || region.to_i.zero?
|
return if region.nil? || region == 'all' || region.to_i.zero?
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
-# Choose a region to filter events with
|
-# Choose a region to filter events with
|
||||||
%nav.region_filter
|
%nav.region_filter
|
||||||
%ul= render partial: '/regions/filter_region',
|
%ul= render partial: '/regions/filter_region', collection: Region.top
|
||||||
collection: Region.where(region: nil).includes(:regions)
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
.radios= render partial: '/regions/selector_region',
|
-# Select a region for an event or organisation
|
||||||
collection: Region.where(region: nil, url: ''),
|
.radios
|
||||||
|
= render partial: '/regions/selector_region',
|
||||||
|
collection: Region.top.local,
|
||||||
locals: { f: f }
|
locals: { f: f }
|
||||||
|
Loading…
Reference in New Issue
Block a user