1
0
mirror of https://github.com/danbee/slugtastic synced 2025-03-04 08:49:05 +00:00
slugtastic/lib/slugtastic/model_additions.rb

13 lines
295 B
Ruby

module Slugtastic
module ModelAdditions
def has_slug name, options = { :from => :title }
before_validation do |record|
return if responds_to?(name) and send(name).present?
send("#{name}=", Slugtastic.generate_slug(send(options[:from])))
end
end
end
end