Ruby on Rails friendly_id, babosa gems, problems with transliteration -


i'm using gems: friendly_id, babosa.

model product.rb:

class product < activerecord::base    extend friendlyid    friendly_id :name, use: [:slugged, :finders]    has_many :tags     def normalize_friendly_id(input)     input.to_s.to_slug.normalize(transliterations: :russian).to_s    end  end 

i launched сonsole, generate slugs existing products:

product.find_each(&:save) 

checking last item:

product.last  #<product id: 4972, name: "ВА 47-63, 2p 2А (c) ekf", created_at: "2016-01-27 11:32:39", updated_at: "2016-01-27 11:32:39", slug: 04b4aa2d-2bb9-46f9-8d49-cbb9d0c3f872"> 

but transliteration wrong. i'm trying doing same in console:

"ВА 47-63, 2p 2А (c) ekf".to_s.to_slug.normalize(transliterations: :russian).to_s => "va-47-63-2p-2a-c-ekf" 

now normal result. can not understand why so.

in same way did transliteration tags, received adequate.

model tag.rb:

class tag < activerecord::base   extend friendlyid   friendly_id :name, use: [:slugged, :finders]   belongs_to :product    def normalize_friendly_id(input)    input.to_s.to_slug.normalize(transliterations: :russian).to_s   end end 

you can fix replacing function on model product.rb:

"input.to_s.to_slug.normalize(transliterations: :russian).to_s" -> "input.to_slug.normalize! :transliterations => [:russian]" 

on model is:

def normalize_friendly_id(text)     text.to_slug.normalize! :transliterations => [:vietnamese] end 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -