mirror of
https://github.com/danbee/slugtastic
synced 2025-03-04 08:49:05 +00:00
Added RDoc.
This commit is contained in:
parent
2a63cb3e02
commit
38893fa515
@ -1,6 +1,14 @@
|
||||
module Slugtastic
|
||||
module ModelAdditions
|
||||
|
||||
# To generate a slug from another value, call <tt>has_slug</tt> in any
|
||||
# ActiveRecord model and pass in the name of the slug attribute.
|
||||
# By default the slug will be generated from the <tt>title</tt> attribute, but
|
||||
# you can specify by adding <tt>:from => {attribute}</tt>.
|
||||
#
|
||||
# class Article < ActiveRecord::Base
|
||||
# has_slug :slug, :from => :title
|
||||
# end
|
||||
def has_slug name, options = { :from => :title }
|
||||
before_validation do |record|
|
||||
send("#{name}=", Slugtastic.generate_slug(send(options[:from]))) if send(name).nil? or send(name).blank?
|
||||
|
||||
Loading…
Reference in New Issue
Block a user