Module: Railslove::Plugins::FindByParam::ClassMethods

Defined in:
lib/find_by_param.rb

Instance Method Summary collapse

Instance Method Details



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/find_by_param.rb', line 18

def make_permalink(options={})
  options[:field] ||= "permalink"

  self.send(:validates_uniqueness_of, options[:field])

  if self.column_names.include?(options[:field].to_s)
    options[:param] = options[:field]
    before_validation(:on => :create){ save_permalink }
  end

  self.permalink_options = options
  extend Railslove::Plugins::FindByParam::SingletonMethods
  include Railslove::Plugins::FindByParam::InstanceMethods
rescue
  # Database is not available (not a problem if we're running rake db:create or rake db:bootstrap)
end