Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update regenerator method
Browse files Browse the repository at this point in the history
aliciapaz committed Jan 23, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent ddc37ed commit d8fff44
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions app/models/organization.rb
Original file line number Diff line number Diff line change
@@ -63,8 +63,17 @@ class Organization < ApplicationRecord
accepts_nested_attributes_for :organization_causes, allow_destroy: true

def regenerate_org_locations_slugs
locations.order(:created_at).each_with_index do |location, index|
location.slug = nil
locations.order(:created_at).each do |location|
base_slug = ein_number.parametrize
slug = base_slug
counter = 1

while Location.exists?(slug: slug)
slug = "#{base_slug}-#{counter}"
counter += 1
end

location.slug = slug
location.save!
end
end

0 comments on commit d8fff44

Please sign in to comment.