norman / friendly_id-globalize

Globalize support for FriendlyId
MIT License
66 stars 32 forks source link

friendly_id-globalize does not override slug parameter #16

Open qbalukom opened 8 years ago

qbalukom commented 8 years ago

This works with just friendly_id:

class Entry < ActiveRecord::Base
  include FriendlyId
  friendly_id :name, use: :slugged
end
entry = Entry.create! name: 'foo bar', slug: nil
# entry.slug == 'foo-bar'

however with globalize:

class Entry < ActiveRecord::Base
  translates :name, :slug

  include FriendlyId
  friendly_id :name, use: [:slugged, :globalize]
end

entry = Entry.create! name: 'foo bar baz', slug: nil
# entry.slug == nil

only this works:

class Entry < ActiveRecord::Base
  translates :name, :slug

  include FriendlyId
  friendly_id :name, use: [:slugged, :globalize]
end

entry = Entry.create! name: 'foo bar'
# entry.slug == 'foo-bar'

even setting should_generate_new_friendly_id? to always return true doesn't change anything. It doesn't matter if it's a new entry or update on an existing one. As long as the 'slug' parameter exists with any content, it's not being overwritten (should_generate is called, slug does get generated, it's just that it has no effect).

kevin-jj commented 8 years ago

@arakell What's the version of Rails in your project?

Senen commented 7 years ago

@arakell i am experiencing the same. Did you find any solutions?

otagi commented 7 years ago

Same issue here, with Rails 4.2.6.

follmann commented 7 years ago

Any news on that? Experiencing the same issue on Rails 5 with the latest globalize, friendly_id and friendly_id-globalize. None of the pointers I found let to a solution.