diff --git a/app/models/category.rb b/app/models/category.rb index 82f09d4..4a27e67 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -20,13 +20,13 @@ class Category < ActiveRecord::Base {:conditions => ['parent_id is null and environment_id = ?', environment.id ]} } - named_scope :on_level, lambda { |parent| {:conditions => {:parent_id => parent}} } + scope :on_level, lambda { |parent| {:conditions => {:parent_id => parent}} } - named_scope :sub_categories, lambda { |category| + scope :sub_categories, lambda { |category| {:conditions => ['categories.path LIKE ? AND categories.id != ?', "%#{category.slug}%", category.id]} } - named_scope :sub_tree, lambda { |category| + scope :sub_tree, lambda { |category| {:conditions => ['categories.path LIKE ?', "%#{category.slug}%"]} } diff --git a/app/models/product.rb b/app/models/product.rb index e8da302..a6fd4c8 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -38,7 +38,7 @@ class Product < ActiveRecord::Base scope :more_recent, :order => "created_at DESC" - named_scope :from_category, lambda { |category| + scope :from_category, lambda { |category| {:joins => :product_category, :conditions => ['categories.path LIKE ?', "%#{category.slug}%"]} if category } -- libgit2 0.21.2