Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
shotengai
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
shotengai
Commits
0883e469
Commit
0883e469
authored
7 years ago
by
ivan Lan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add manager to Product
parent
ea8c9629
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
2 deletions
+18
-2
1_create_shotengai_products_and_orders.rb
db/migrate/1_create_shotengai_products_and_orders.rb
+4
-0
product.rb
lib/shotengai/product.rb
+7
-2
shotengai_products.rb
spec/factories/shotengai_products.rb
+7
-0
No files found.
db/migrate/1_create_shotengai_products_and_orders.rb
View file @
0883e469
...
@@ -13,10 +13,14 @@ class CreateShotengaiProductsAndOrders < ActiveRecord::Migration[5.1]
...
@@ -13,10 +13,14 @@ class CreateShotengaiProductsAndOrders < ActiveRecord::Migration[5.1]
# Single Table Inheritance
# Single Table Inheritance
t
.
string
:type
t
.
string
:type
t
.
json
:meta
t
.
json
:meta
t
.
integer
:manager_id
t
.
string
:manager_type
t
.
timestamps
t
.
timestamps
end
end
add_index
:shotengai_products
,
[
:manager_id
,
:manager_type
]
add_index
:shotengai_products
,
:type
add_index
:shotengai_products
,
:type
create_table
:shotengai_series
do
|
t
|
create_table
:shotengai_series
do
|
t
|
...
...
This diff is collapsed.
Click to expand it.
lib/shotengai/product.rb
View file @
0883e469
...
@@ -15,17 +15,22 @@ module Shotengai
...
@@ -15,17 +15,22 @@ module Shotengai
# detail :json
# detail :json
# type :string(255)
# type :string(255)
# meta :json
# meta :json
# manager_id :integer
# manager_type :string(255)
# created_at :datetime not null
# created_at :datetime not null
# updated_at :datetime not null
# updated_at :datetime not null
#
#
# Indexes
# Indexes
#
#
# index_shotengai_products_on_type (type)
# index_shotengai_products_on_manager_id_and_manager_type (manager_id,manager_type)
# index_shotengai_products_on_type (type)
#
#
class
Shotengai
::
Product
<
ActiveRecord
::
Base
class
Shotengai
::
Product
<
ActiveRecord
::
Base
require
'acts-as-taggable-on'
require
'acts-as-taggable-on'
self
.
table_name
=
'shotengai_products'
self
.
table_name
=
'shotengai_products'
belongs_to
:manager
,
polymorphic:
true
,
optional:
true
validate
:check_spec
,
if: :spec
validate
:check_spec
,
if: :spec
include
AASM_DLC
include
AASM_DLC
...
...
This diff is collapsed.
Click to expand it.
spec/factories/shotengai_products.rb
View file @
0883e469
...
@@ -14,9 +14,16 @@
...
@@ -14,9 +14,16 @@
# detail :json
# detail :json
# type :string(255)
# type :string(255)
# meta :json
# meta :json
# manager_id :integer
# manager_type :string(255)
# created_at :datetime not null
# created_at :datetime not null
# updated_at :datetime not null
# updated_at :datetime not null
#
#
# Indexes
#
# index_shotengai_products_on_manager_id_and_manager_type (manager_id,manager_type)
# index_shotengai_products_on_type (type)
#
FactoryGirl
.
define
do
FactoryGirl
.
define
do
factory
:test_good
,
class:
'TestGood'
do
factory
:test_good
,
class:
'TestGood'
do
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment