friendly_id-globalize icon indicating copy to clipboard operation
friendly_id-globalize copied to clipboard

friendly_id-globalize does not override slug parameter

Open qbalukom opened this issue 8 years ago • 4 comments

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).

qbalukom avatar Jun 08 '16 12:06 qbalukom

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

kevin-jj avatar Jul 30 '16 01:07 kevin-jj

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

Senen avatar Nov 16 '16 19:11 Senen

Same issue here, with Rails 4.2.6.

otagi avatar Dec 26 '16 17:12 otagi

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.

follmann avatar Jun 12 '17 09:06 follmann