Reputation: 1104
I am using the friendly_id gem version 4.0.9 in Rails 3, and I want to change the default sequence separator from -
to _
.
I tried this but it doesn't work:
class Restaurant < ActiveRecord::Base
extend FriendlyId
friendly_id do |config|
config.base = :name
config.use :slugged
config.sequence_separator = "_"
end
.....
end
Upvotes: 3
Views: 994
Reputation: 406
For Friendly_Id Gem 5.x with Rails 4.x (Might also work with lower versions of Friendly_Id Gem or Rails)
Add the following method to the model file where you are using Friendly_Id to generate slugs-
def normalize_friendly_id(string)
super.gsub("-", "_")
end
Upvotes: 3
Reputation: 15788
Taken from the gem's tests on GitHub:
friendly_id :name, :use => :slugged, :sequence_separator => "_"
Should work...
Upvotes: 2