You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For globalized slugs, when both modules are enabled, scope and history, scope is not applied for new records, only for updated ones.
You can reproduce it creating two records with the same values excepting scoped data. Slug should be the same for both, but it doesn't. To let the same value, you have to modify translated slug with the same value of first record.
I think that the problem could be in the scope_for_slug_generator method of the history module version provided for this gem. Only when record exists the scope is used to get the slug table relationship.
Changing the order of friendly_id_config.uses?(:scoped) condition all works fine and slug is generated correctly:
@@ -109,12 +109,11 @@ method.
# used slug.
def scope_for_slug_generator
relation = super
- return relation if new_record?
- relation = relation.merge(Slug.where('sluggable_id <> ?', id))
if friendly_id_config.uses?(:scoped)
relation = relation.where(Slug.arel_table[:scope].eq(serialized_scope))
end
- relation
+ relation = relation.merge(Slug.where('sluggable_id <> ?', id)) unless new_record?
+ return relation
end
The text was updated successfully, but these errors were encountered:
For globalized slugs, when both modules are enabled, scope and history, scope is not applied for new records, only for updated ones.
You can reproduce it creating two records with the same values excepting scoped data. Slug should be the same for both, but it doesn't. To let the same value, you have to modify translated slug with the same value of first record.
I think that the problem could be in the
scope_for_slug_generator
method of the history module version provided for this gem. Only when record exists the scope is used to get the slug table relationship.Changing the order of
friendly_id_config.uses?(:scoped)
condition all works fine and slug is generated correctly:The text was updated successfully, but these errors were encountered: