19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/mm-sluggable.rb', line 19
def sluggable(to_slug = :title, options = {})
class_attribute :slug_options
self.slug_options = {
:to_slug => to_slug,
:key => :slug,
:index => true,
:method => :parameterize,
:scope => nil,
:max_length => 256,
:callback => [:before_validation, {:on => :create}],
:force => false
}.merge(options)
key slug_options[:key], String, :index => slug_options[:index]
if slug_options[:callback].is_a?(Array)
self.send(slug_options[:callback][0], :set_slug, slug_options[:callback][1])
else
self.send(slug_options[:callback], :set_slug)
end
end
|