ruby on rails - How to configure sequence separator with underscore `_` of friendly_id gem -


i using friendly_id gem version 3.3.3.0 in rails 3.2

i have defined friendly id following :-

class user < activerecord::base     has_friendly_id :name, use: :slugged, sequence_separator: '_', max_length: 32  end 

i have used sequence separator _

but when execute query on console separating using _(underscore) works fines --(double dash)

i have 3 user cached_slug user_1 user_2 , user_3

when trying find records cached slug generates following query.

using - _(underscore)

for - `user_1` user.find("user_1") select sluggable_id slugs ((slugs.sluggable_type = 'user' , slugs.name = 'user_1' , slugs.sequence = 1))  - `user_2` user.find("user_2") select sluggable_id slugs ((slugs.sluggable_type = 'user' , slugs.name = 'user_2' , slugs.sequence = 1))  - `user_3` user.find("user_3") select sluggable_id slugs ((slugs.sluggable_type = 'user' , slugs.name = 'user_3' , slugs.sequence = 1))  

its not taking sequence from cached slug.

using - --(double dash)

for - `user--1` user.find("user--1") select sluggable_id slugs ((slugs.sluggable_type = 'user' , slugs.name = 'user' , slugs.sequence = 1))  - `user--2` user.find("user--2") select sluggable_id slugs ((slugs.sluggable_type = 'user' , slugs.name = 'user' , slugs.sequence = 2))  - `user--3` user.find("user--3") select sluggable_id slugs ((slugs.sluggable_type = 'user' , slugs.name = 'user' , slugs.sequence =3))  

--(double dash) identifies sequence properly

let me know if missing include.

**update - **

i debug gem code , found refers sequence_separator -- instead of have defined in model _

class string   def parse_friendly_id(separator = nil)     separator ||= friendlyid::configuration::defaults[:sequence_separator]     name, sequence = split(/#{regexp.escape(separator)}(\d+)?\z/)     return name, (sequence ||= 1).to_i   end end 


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -