Browse Source

Use a gem 🙃

pull/816/head
Kat 3 years ago
parent
commit
9a090c501e
  1. 1
      Gemfile
  2. 3
      Gemfile.lock
  3. 4
      app/models/application_record.rb
  4. 5
      app/models/location.rb
  5. 6
      app/models/organisation.rb
  6. 6
      app/models/scheme.rb
  7. 6
      app/models/user.rb

1
Gemfile

@ -55,6 +55,7 @@ gem "redis"
gem "sentry-rails" gem "sentry-rails"
gem "sentry-ruby" gem "sentry-ruby"
# Possessives in strings # Possessives in strings
gem "auto_strip_attributes"
gem "possessive" gem "possessive"
group :development, :test do group :development, :test do

3
Gemfile.lock

@ -81,6 +81,8 @@ GEM
addressable (2.8.0) addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0) public_suffix (>= 2.0.2, < 5.0)
ast (2.4.2) ast (2.4.2)
auto_strip_attributes (2.6.0)
activerecord (>= 4.0)
aws-eventstream (1.2.0) aws-eventstream (1.2.0)
aws-partitions (1.609.0) aws-partitions (1.609.0)
aws-sdk-core (3.131.3) aws-sdk-core (3.131.3)
@ -428,6 +430,7 @@ PLATFORMS
x86_64-linux x86_64-linux
DEPENDENCIES DEPENDENCIES
auto_strip_attributes
aws-sdk-s3 aws-sdk-s3
bootsnap (>= 1.4.4) bootsnap (>= 1.4.4)
bundler-audit bundler-audit

4
app/models/application_record.rb

@ -1,7 +1,3 @@
class ApplicationRecord < ActiveRecord::Base class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true self.abstract_class = true
def strip_whitespaces
fields_to_strip.each { |field| self[field] = self[field].strip if field.present? }
end
end end

5
app/models/location.rb

@ -6,11 +6,8 @@ class Location < ApplicationRecord
has_paper_trail has_paper_trail
before_save :lookup_postcode!, if: :postcode_changed? before_save :lookup_postcode!, if: :postcode_changed?
before_validation :strip_whitespaces
def fields_to_strip auto_strip_attributes :name
%w[name]
end
attr_accessor :add_another_location attr_accessor :add_another_location

6
app/models/organisation.rb

@ -12,11 +12,7 @@ class Organisation < ApplicationRecord
has_paper_trail has_paper_trail
before_validation :strip_whitespaces auto_strip_attributes :name
def fields_to_strip
%w[name]
end
PROVIDER_TYPE = { PROVIDER_TYPE = {
LA: 1, LA: 1,

6
app/models/scheme.rb

@ -19,11 +19,7 @@ class Scheme < ApplicationRecord
validate :validate_confirmed validate :validate_confirmed
before_validation :strip_whitespaces auto_strip_attributes :service_name
def fields_to_strip
%w[service_name]
end
SENSITIVE = { SENSITIVE = {
No: 0, No: 0,

6
app/models/user.rb

@ -27,11 +27,7 @@ class User < ApplicationRecord
has_one_time_password(encrypted: true) has_one_time_password(encrypted: true)
before_validation :strip_whitespaces auto_strip_attributes :name
def fields_to_strip
%w[name]
end
ROLES = { ROLES = {
data_provider: 1, data_provider: 1,

Loading…
Cancel
Save