Pergunta

Using:

Rails: 3.0.3 Friendly_id: 3.2.1

I am building a website with (currently) two locales, :se & :en where I am using friendly_id to get SEO-friendly url.

Currently, it works fine but I am trying to get it to work with locales and end up in dead ends all the time.

What does work:

I have created friendly_id for name that currently exist in a cached_slug column. This works fine and I can both use Calculation.find("calculation-name") and get url:s with it e.g. domain.com/calculation-name

What doesn't work: After implementing this: http://rdoc.info/github/norman/friendly_id/master/FriendlyId/I18n , I have now two columns slug_en & slug_se with translated versions of each friendly_id. I have also added the indices in that guide.

I can't get my app to find them (neither by Calculation.find("this-swedish-translation") or by url domain.com/this-swedish-translation) though and I have Googled it thoroughly without luck.

I don't know if I need to alter something in the model. Every attribute related to I18n at has_friendly_id gives me error messages, such as:

  • default_locale
  • locale

I cannot use attributes such as :use => slugged or :use => :locale etc either.

My first guess is that I am using a version that does not support I18n/locales? It is tricky to understand what the documentation is actually referring to...

My big question is though: What is wrong with my assumptions and/or code? Why can I not make my app use the slug_en & slug_es as it is supposed to work?

# Model
has_friendly_id :name, :use_slug => true, :max_length => 255, :approximate_ascii => true, :ascii_approximation_options => :latin
Foi útil?

Solução

This problem was solved by updating to 4.0.0. I still don't understand why it didn't work with the previous version (as far as I understand, it should).

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top