Generate Permalink


/ Published in: Rails
Save to your folder(s)



Copy this code and paste it in your HTML
  1. before_create :generate_permalink
  2.  
  3. def geerate_permanlink
  4. @attributes['permalink'] = name.downcase.gsub(/\s+/,'_').gsub(/[^a-zA-Z0-9_]+/,'')
  5. end

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.