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
9e1bb9af
Commit
9e1bb9af
authored
Sep 12, 2017
by
ivan Lan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add touch: true to belongs_to
parent
d1cea924
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
14 additions
and
12 deletions
+14
-12
cart.rb
lib/shotengai/cart.rb
+2
-1
catalog.rb
lib/shotengai/catalog.rb
+1
-1
order.rb
lib/shotengai/order.rb
+3
-2
product.rb
lib/shotengai/product.rb
+1
-1
series.rb
lib/shotengai/series.rb
+2
-2
snapshot.rb
lib/shotengai/snapshot.rb
+5
-5
No files found.
lib/shotengai/cart.rb
View file @
9e1bb9af
...
...
@@ -58,7 +58,8 @@ module Shotengai
self
.
model_name
.
singular
.
to_sym
,
class_name:
self
.
name
,
optional:
true
,
foreign_key: :shotengai_order_id
foreign_key: :shotengai_order_id
,
touch:
true
,
)
end
end
...
...
lib/shotengai/catalog.rb
View file @
9e1bb9af
...
...
@@ -25,7 +25,7 @@ module Shotengai
class
<<
self
def
inherited
subclass
subclass
.
has_many
:sub_catalogs
,
class_name:
subclass
.
name
,
foreign_key: :super_catalog_id
subclass
.
belongs_to
:super_catalog
,
class_name:
subclass
.
name
,
optional:
true
subclass
.
belongs_to
:super_catalog
,
class_name:
subclass
.
name
,
optional:
true
,
touch:
true
# subclass.instance_eval("def klass; #{subclass}; end")
super
end
...
...
lib/shotengai/order.rb
View file @
9e1bb9af
...
...
@@ -30,7 +30,7 @@ module Shotengai
class
Order
<
ActiveRecord
::
Base
self
.
table_name
=
'shotengai_orders'
belongs_to
:buyer
,
polymorphic:
true
,
optional:
true
belongs_to
:buyer
,
polymorphic:
true
,
optional:
true
,
touch:
true
default_scope
{
where
.
not
(
status:
'cart'
)
}
scope
:status_is
,
->
(
status
)
{
where
(
status
.
blank?
.!
&&
{
status:
status
})
}
...
...
@@ -156,7 +156,8 @@ module Shotengai
self
.
model_name
.
singular
.
to_sym
,
class_name:
self
.
name
,
optional:
true
,
foreign_key: :shotengai_order_id
foreign_key: :shotengai_order_id
,
touch:
true
,
)
end
...
...
lib/shotengai/product.rb
View file @
9e1bb9af
...
...
@@ -30,7 +30,7 @@ module Shotengai
require
'acts-as-taggable-on'
self
.
table_name
=
'shotengai_products'
belongs_to
:manager
,
polymorphic:
true
,
optional:
true
belongs_to
:manager
,
polymorphic:
true
,
optional:
true
,
touch:
true
validate
:check_spec
,
if: :spec
include
AASM_DLC
...
...
lib/shotengai/series.rb
View file @
9e1bb9af
...
...
@@ -51,8 +51,8 @@ module Shotengai
def
add_associations
# belongs to Product
@subclass
.
belongs_to
:product
,
foreign_key: :shotengai_product_id
,
class_name:
@product_name
@subclass
.
belongs_to
@product_name
.
underscore
.
to_sym
,
foreign_key: :shotengai_product_id
,
class_name:
@product_name
@subclass
.
belongs_to
:product
,
foreign_key: :shotengai_product_id
,
class_name:
@product_name
,
touch:
true
@subclass
.
belongs_to
@product_name
.
underscore
.
to_sym
,
foreign_key: :shotengai_product_id
,
class_name:
@product_name
,
touch:
true
# has many snapshot
@subclass
.
has_many
:snapshots
,
class_name:
"
#{
@product_name
}
Snapshot"
,
foreign_key: :shotengai_series_id
end
...
...
lib/shotengai/snapshot.rb
View file @
9e1bb9af
...
...
@@ -34,9 +34,9 @@ module Shotengai
validate
:cannot_edit_if_order_is_paid
belongs_to
:shotengai_order
,
foreign_key: :shotengai_order_id
,
class_name:
'Shotengai::Order'
,
optional:
true
class_name:
'Shotengai::Order'
,
optional:
true
,
touch:
true
belongs_to
:shotengai_cart
,
foreign_key: :shotengai_order_id
,
class_name:
'Shotengai::Cart'
,
optional:
true
class_name:
'Shotengai::Cart'
,
optional:
true
,
touch:
true
scope
:in_order
,
->
{
joins
(
"
...
...
@@ -58,8 +58,8 @@ module Shotengai
product_name
=
/^(.+)Snapshot/
.
match
(
subclass
.
name
)[
1
]
series_name
=
"
#{
product_name
}
Series"
# belongs to Series
subclass
.
belongs_to
:series
,
foreign_key: :shotengai_series_id
,
class_name:
series_name
subclass
.
belongs_to
series_name
.
underscore
.
to_sym
,
foreign_key: :shotengai_series_id
,
class_name:
series_name
subclass
.
belongs_to
:series
,
foreign_key: :shotengai_series_id
,
class_name:
series_name
,
touch:
true
subclass
.
belongs_to
series_name
.
underscore
.
to_sym
,
foreign_key: :shotengai_series_id
,
class_name:
series_name
,
touch:
true
super
end
end
...
...
@@ -85,7 +85,7 @@ module Shotengai
end
def
cut_stock
self
.
series
.
cut_stock
self
.
series
.
cut_stock
(
self
.
count
)
end
def
meta
...
...
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