Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[V2] Slugs #54

Merged
merged 7 commits into from
Sep 18, 2024
Merged

[V2] Slugs #54

merged 7 commits into from
Sep 18, 2024

Conversation

CalvinWalzel
Copy link
Owner

This pull request introduces the friendly_id gem to replace numeric IDs with human-readable slugs for URLs. This involves changes across models, controllers, serializers, and database migrations. The most important changes include adding the friendly_id gem, updating models to use slugs, and modifying controllers and serializers to support the new slugs.

Integration of friendly_id gem:

  • Added friendly_id gem to Gemfile.
  • Created an initializer for friendly_id with global configuration. (config/initializers/friendly_id.rb)

Model updates:

  • Updated City, Company, Continent, Country, and Region models to use friendly_id for generating slugs and ensuring slug presence validation. (app/models/city.rb, app/models/company.rb, app/models/continent.rb, app/models/country.rb, app/models/region.rb) [1] [2] [3] [4] [5]

Controller and serializer updates:

  • Modified CompaniesController to use slugs instead of numeric IDs. (app/controllers/companies_controller.rb)
  • Updated CompanySerializer and GeoFragmentSerializer to include slugs. (app/serializers/company_serializer.rb, app/serializers/geo_fragment_serializer.rb) [1] [2]

Frontend updates:

  • Modified frontend components to use slugs in URLs instead of numeric IDs. (app/frontend/pages/companies/index.tsx, app/frontend/types/company.ts, app/frontend/types/geo_fragment.ts) [1] [2] [3]

Database migrations:

  • Added database migrations to create slugs for existing records and ensure uniqueness and presence of slugs. (db/migrate/20240918173013_create_friendly_id_slugs.rb, db/migrate/20240918173030_add_slug_to_companies.rb, db/migrate/20240918180412_add_slug_to_continents.rb, db/migrate/20240918181314_add_slug_to_countries.rb, db/migrate/20240918181525_add_slug_to_region.rb, db/migrate/20240918181921_add_slug_to_city.rb) [1] [2] [3] [4] [5] [6]

@CalvinWalzel CalvinWalzel self-assigned this Sep 18, 2024
@CalvinWalzel CalvinWalzel merged commit 79c8ebd into version-2 Sep 18, 2024
4 checks passed
@CalvinWalzel CalvinWalzel deleted the v2/slugs branch September 18, 2024 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant