Rails: friendly_id & globalize not checking translation tables for conflicts

773 Views Asked by At

I'm using friendly_id (4.10.1) and globalize (3.0.0) in my Rails 3.2.14 app:

# globalize3
translates :title, :slug

# friendly_id    
extend FriendlyId
friendly_id :title, use: [:slugged, :globalize]

When I save my inputs, friendly_id checks for slug collisions:

SELECT "pages".* FROM "pages" WHERE
("slug" = 'my-title' OR "slug" LIKE 'my-title--%') AND (id <> 1)
ORDER BY LENGTH("slug") DESC, "slug" DESC LIMIT 1

Friendly_id should use the translation table page_translations for this, because the entry in the original table pages is kinda random when you use multiple locales.

And that's the problem: friendly_id only recognizes slug collisions for one language/locale.

Does anyone have an idea how to alter the query for full globalize support? Thank you very much in advance!

0

There are 0 best solutions below