Module: Spree::Core::Permalinks::ClassMethods
- Defined in:
- lib/spree/core/permalinks.rb
Instance Method Summary collapse
- #find_by_param(value, *args) ⇒ Object
- #find_by_param!(value, *args) ⇒ Object
- #make_permalink(options = {}) ⇒ Object
- #permalink_field ⇒ Object
- #permalink_order ⇒ Object
- #permalink_prefix ⇒ Object
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 |
#make_permalink(options = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/spree/core/permalinks.rb', line 13 def make_permalink(={}) [:field] ||= :permalink self. = validates [:field], :uniqueness => true if self.table_exists? && self.column_names.include?([:field].to_s) before_validation(:on => :create) { save_permalink } end end |
#permalink_field ⇒ Object
32 33 34 |
# File 'lib/spree/core/permalinks.rb', line 32 def permalink_field [:field] end |
#permalink_order ⇒ Object
40 41 42 43 |
# File 'lib/spree/core/permalinks.rb', line 40 def permalink_order order = [:order] "#{order} ASC," if order end |
#permalink_prefix ⇒ Object
36 37 38 |
# File 'lib/spree/core/permalinks.rb', line 36 def permalink_prefix [:prefix] || "" end |