Class: Product
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Product
- Includes:
- Forge::Reorderable
- Defined in:
- lib/forge/app/models/product.rb
Class Method Summary collapse
Instance Method Summary collapse
- #all_breadcrumbs(join_character = ' > ') ⇒ Object
- #options_hash ⇒ Object
- #options_yaml ⇒ Object
-
#quantity ⇒ Object
for when the product is used in the cart or in an order hash.
- #quantity=(quantity) ⇒ Object
- #to_param ⇒ Object
Methods included from Forge::Reorderable
Class Method Details
.find_with_images(id) ⇒ Object
58 59 60 |
# File 'lib/forge/app/models/product.rb', line 58 def self.find_with_images(id) includes(:images).order('product_images.list_order').find(id) end |
Instance Method Details
#all_breadcrumbs(join_character = ' > ') ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/forge/app/models/product.rb', line 44 def (join_character = ' > ') @all_breadcrumbs = [] self.product_categories.each do |category| @breadcrumb = category. @all_breadcrumbs << @breadcrumb end if @all_breadcrumbs.blank? @all_breadcrumbs = "No categories." else @all_breadcrumbs.join(', ') end end |
#options_hash ⇒ Object
40 41 42 |
# File 'lib/forge/app/models/product.rb', line 40 def YAML::load(self.) end |
#options_yaml ⇒ Object
36 37 38 |
# File 'lib/forge/app/models/product.rb', line 36 def self. end |
#quantity ⇒ Object
for when the product is used in the cart or in an order hash
24 25 26 |
# File 'lib/forge/app/models/product.rb', line 24 def quantity @quantity ||= 1 end |
#quantity=(quantity) ⇒ Object
28 29 30 |
# File 'lib/forge/app/models/product.rb', line 28 def quantity=(quantity) @quantity = quantity end |
#to_param ⇒ Object
32 33 34 |
# File 'lib/forge/app/models/product.rb', line 32 def to_param "#{id}-#{title.gsub(/[^a-z0-9]+/i, '-')}".downcase end |