added brands

This commit is contained in:
Edin Dazdarevic
2015-03-28 14:38:15 +01:00
parent 6c7a1b962f
commit 71fbde93de
11 changed files with 35 additions and 5 deletions

View File

@@ -4,7 +4,8 @@ def prepare_items_for_mass_display(items)
:include => [
:unit ,
:multi_media_descriptions ,
:sub_category
:sub_category,
:brand
])
end
@@ -94,4 +95,4 @@ get '/item/item_group/:item_group_id/offset/:offset/limit/:limit' do |item_group
items = ItemGroup.find(item_group_id).all_items(offset, limit)
prepare_items_for_mass_display(items)
end
end

View File

@@ -0,0 +1,9 @@
class CreateBrands < ActiveRecord::Migration
def change
create_table :brands do |t|
t.string :name
end
add_column :items, :brand_id, :integer
end
end

View File

@@ -11,11 +11,15 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20150324044314) do
ActiveRecord::Schema.define(version: 20150328132019) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
create_table "brands", force: :cascade do |t|
t.string "name"
end
create_table "carts", force: :cascade do |t|
t.integer "user_id"
t.boolean "ordered", default: false
@@ -125,6 +129,7 @@ ActiveRecord::Schema.define(version: 20150324044314) do
t.decimal "weight", precision: 5, scale: 3
t.integer "supplier_id"
t.integer "delivery_time_estimation_id"
t.integer "brand_id"
end
create_table "link_banners", force: :cascade do |t|

View File

@@ -0,0 +1,3 @@
class Brand < ActiveRecord::Base
has_many :items
end

View File

@@ -1,5 +1,6 @@
class Item < ActiveRecord::Base
belongs_to :unit
belongs_to :brand
has_many :multi_media_descriptions
belongs_to :sub_category