mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Add before save to check the instagram link pattern
This commit is contained in:
@@ -80,6 +80,8 @@ class Enterprise < ActiveRecord::Base
|
||||
before_validation :set_unused_address_fields
|
||||
after_validation :geocode_address
|
||||
|
||||
before_save :check_instagram_pattern
|
||||
|
||||
after_touch :touch_distributors
|
||||
after_create :set_default_contact
|
||||
after_create :relate_to_owners_enterprises
|
||||
@@ -425,4 +427,9 @@ class Enterprise < ActiveRecord::Base
|
||||
where('enterprises.id != ?', self.id).
|
||||
each(&:touch)
|
||||
end
|
||||
|
||||
def check_instagram_pattern
|
||||
return if self.instagram.blank? || self.instagram.exclude?('www.instagram.com')
|
||||
self.instagram = "@#{self.instagram.split('/').last}"
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user