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



22
23
24
# File 'lib/spree/core/permalinks.rb', line 22

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

#find_by_param!(value, *args) ⇒ Object



26
27
28
# File 'lib/spree/core/permalinks.rb', line 26

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


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

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

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


30
31
32
# File 'lib/spree/core/permalinks.rb', line 30

def permalink_field
  permalink_options[:field]
end


38
39
40
41
# File 'lib/spree/core/permalinks.rb', line 38

def permalink_order
  order = permalink_options[:order]
  "#{order} ASC," if order
end


34
35
36
# File 'lib/spree/core/permalinks.rb', line 34

def permalink_prefix
  permalink_options[:prefix] || ""
end