Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

scope not updated if slug already exists #4

@hazah

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

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