Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localized Slugs with same translations are not generated #153

Closed
exocode opened this issue Jan 23, 2014 · 5 comments
Closed

Localized Slugs with same translations are not generated #153

exocode opened this issue Jan 23, 2014 · 5 comments

Comments

@exocode
Copy link

exocode commented Jan 23, 2014

I have a model

class Category
  field :name, String, localize: true
  slug :name, localize: true
end

If I am submitting a new Category an it has the same name in both translations only one slug will be generated:

THIS WORKS:
Category.create(name_translations: {"en"=>"Open Air", "de"=>"Freiluft"} )

THIS DOES NOT WORK:
Category.create(name_translations: {"en"=>"Open Air", "de"=>"Open Air"} )

I18n.locale = :de
Category.find("open-air")
#<Category _id: 52e113982d289e83ee000038, parent_id: "52e113982d289e83ee000031", parent_ids: ["52e113982d289e83ee000031"], name: {"en"=>"Open Air", "de"=>"Open Air"}, description: nil, _slugs: {"en"=>[], "de"=>["open-air"]}, location_ids: nil, service_ids: nil>

I18n.locale = :en
Category.find("open-air")
# nil

What I am missing?

@digitalplaywright
Copy link
Collaborator

I added a spec on master in commit 8b2e023 testing this scenario and I can not replicate it.

Is there something I am doing different in the spec compared to what you are doing?

@exocode
Copy link
Author

exocode commented Jan 25, 2014

Hi, I copy pasted your suggestion:

  • mongoid (3.1.5)
  • mongoid_slug (3.2.0)
>> page = Musicstyle.new
#<Musicstyle _id: 52e3e7302d289ec73d00006c, parent_id: nil, parent_ids: [], n(name): nil, dsc(description): nil, _slugs: {"en"=>[]}, location_ids: nil, user_ids: nil>

>> page.name_translations = {"en" => "Title on English", "nl" => "Title on English"}
{"en"=>"Title on English", "nl"=>"Title on English"}

>> page.save!
true

>> page.reload
#<Musicstyle _id: 52e3e7302d289ec73d00006c, parent_id: nil, parent_ids: [], n(name): {"en"=>"Title on English", "nl"=>"Title on English"}, dsc(description): nil, _slugs: {"en"=>[], "nl"=>["title-on-english"]}, location_ids: nil, user_ids: nil>

>> page["_slugs"]
{"en"=>[], "nl"=>["title-on-english"]}

>> page.name_translations = {"en" => "Title on English123", "de" => "Title on English123"}
{"en"=>"Title on English123", "de"=>"Title on English123"}

>> page.save!
true

>> page.reload
#<Musicstyle _id: 52e3e7302d289ec73d00006c, parent_id: nil, parent_ids: [], n(name): {"en"=>"Title on English123", "de"=>"Title on English123"}, dsc(description): nil, _slugs: {"en"=>[], "nl"=>["title-on-english"], "de"=>["title-on-english123"]}, location_ids: nil, user_ids: nil>

>> page["_slugs"]
{"en"=>[], "nl"=>["title-on-english"], "de"=>["title-on-english123"]}

@digitalplaywright
Copy link
Collaborator

The most recent version of the I8n support in rails seems to fix your problem. We test this as part of your testsuite:
https://github.com/digitalplaywright/mongoid-slug/blob/master/spec/mongoid/slug_spec.rb#L883

Please let me know if this is not true for you.

@digitalplaywright
Copy link
Collaborator

Any updates on this?

@digitalplaywright
Copy link
Collaborator

I am closing this for now since I can't reproduce the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants