Skip to content
This repository was archived by the owner on May 14, 2026. It is now read-only.
This repository was archived by the owner on May 14, 2026. It is now read-only.

scope not updated if slug already exists #4

Description

@hazah

Slug.transaction do
   slugs.update_all(active: false)
   slugs.where(slug: valid_slugs_in_use.first).update_all(active: true)
end
return

if the scope isn't already in the record, it does not seem to get saved. A new slug is not generated either.
all I did to fix it is the following in your code.


Slug.transaction do
  slugs.update_all(active: false)
  slugs.where(slug: valid_slugs_in_use.first).update_all(
  active: true,
  scope: self.class._slug_scope.try(:call, self))
end
return

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions