item groups now have order - start page is now item group 1 (configurable in globals)

This commit is contained in:
Senad Uka
2015-04-21 06:39:30 +02:00
parent ecbe58c626
commit c9949c444a
17 changed files with 126 additions and 12 deletions

View File

@@ -4,6 +4,9 @@ class Item < ActiveRecord::Base
has_many :multi_media_descriptions
belongs_to :sub_category
has_many :item_groups, through: :item_in_groups
attr_accessor :count # used for cart
def attributes
super.merge('count' => self.count)

View File

@@ -1,8 +1,10 @@
class ItemGroup < ActiveRecord::Base
has_and_belongs_to_many :items, :join_table => 'item_item_groups'
has_many :item_in_groups
has_many :items, through: :item_in_groups
def all_items(offset, limit)
self.items.where(on_display: true).order(:created_at).limit(limit).offset(offset).all
self.items.where(on_display: true).order("item_in_groups.position").limit(limit).offset(offset).all
end
end

View File

@@ -0,0 +1,4 @@
class ItemInGroup < ActiveRecord::Base
belongs_to :item_group
belongs_to :item
end