Module: Spree::Core::Permalinks::ClassMethods

Defined in:
lib/spree/core/permalinks.rb

Instance Method Summary collapse

Instance Method Details

#find_by_param(value, *args) ⇒ Object



24
25
26
# File 'lib/spree/core/permalinks.rb', line 24

def find_by_param(value, *args)
  self.send("find_by_#{permalink_field}", value, *args)
end

#find_by_param!(value, *args) ⇒ Object



28
29
30
# File 'lib/spree/core/permalinks.rb', line 28

def find_by_param!(value, *args)
  self.send("find_by_#{permalink_field}!", value, *args)
end


13
14
15
16
17
18
19
20
21
22
# File 'lib/spree/core/permalinks.rb', line 13

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

  validates_uniqueness_of permalink_options[:field]

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


32
33
34
# File 'lib/spree/core/permalinks.rb', line 32

def permalink_field
  permalink_options[:field]
end