Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Post < ActiveRecord::Base
- before_save :generate_slug
- def generate_slug
- self.title = self.title.mb_chars.normalize(:kd).gsub(/[^\x00-\x7F]/n, '').to_s.gsub(/[']+/, '').gsub(/\W+/, ' ').strip.downcase.gsub!(' ', '-')
- end
- end
Add Comment
Please, Sign In to add comment