diff --git a/app/models/scheme.rb b/app/models/scheme.rb index 3c5347438..2465c95dd 100644 --- a/app/models/scheme.rb +++ b/app/models/scheme.rb @@ -3,7 +3,7 @@ class Scheme < ApplicationRecord has_many :locations has_many :case_logs - scope :filter_by_id, ->(id) { where(id: (id.start_with?("S") ? id[1..-1] : id))} + scope :filter_by_id, ->(id) { where(id: (id.start_with?("S") ? id[1..] : id)) } scope :search_by_service_name, ->(name) { where("service_name ILIKE ?", "%#{name}%") } scope :search_by_postcode, ->(postcode) { joins(:locations).where("locations.postcode ILIKE ?", "%#{postcode.delete(' ')}%") } scope :search_by, ->(param) { search_by_postcode(param).or(search_by_service_name(param)).or(filter_by_id(param)).distinct }