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
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_uniqueness_of [:field] 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 |