added brands
This commit is contained in:
@@ -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
|
||||
|
||||
9
front-api/db/migrate/20150328132019_create_brands.rb
Normal file
9
front-api/db/migrate/20150328132019_create_brands.rb
Normal 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
|
||||
@@ -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|
|
||||
|
||||
3
front-api/models/brand.rb
Normal file
3
front-api/models/brand.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
class Brand < ActiveRecord::Base
|
||||
has_many :items
|
||||
end
|
||||
@@ -1,5 +1,6 @@
|
||||
class Item < ActiveRecord::Base
|
||||
belongs_to :unit
|
||||
belongs_to :brand
|
||||
has_many :multi_media_descriptions
|
||||
belongs_to :sub_category
|
||||
|
||||
|
||||
Reference in New Issue
Block a user