Advertisement
Guest User

FriendlyId monkey patch

a guest
Jun 28th, 2014
427
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.30 KB | None | 0 0
  1. # in /config/initializers/friendly_id.rb
  2.  
  3. module FrieldlyId
  4.   module Slugged
  5.     def resolve_friendly_id_conflict(candidates)
  6.     my_cool_unique_suffix = SecureRandom.hex(4) # some shorter suffix
  7.     candidates.first + friendly_id_config.sequence_separator + my_cool_unique_suffix
  8.     end
  9.   end
  10. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement