friendly_id-globalize
friendly_id-globalize copied to clipboard
friendly_id-globalize does not override slug parameter
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).
@arakell What's the version of Rails in your project?
@arakell i am experiencing the same. Did you find any solutions?
Same issue here, with Rails 4.2.6.
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.