Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
VenShop
Overview
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
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Dao Minh Nhut
VenShop
Commits
5e245ce1
Commit
5e245ce1
authored
Aug 12, 2015
by
Dao Minh Nhut
Browse files
Options
Browse Files
Download
Plain Diff
solr search, insert, update, delete
parents
d38e9224
f67de3d0
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
60 additions
and
5 deletions
+60
-5
app/controllers/admins/users_controller.rb
+6
-0
app/controllers/carts_controller.rb
+10
-0
app/controllers/categories_controller.rb
+4
-0
app/models/product.rb
+4
-0
app/views/admins/products/show.html.erb
+6
-0
config/routes.rb
+7
-0
db/migrate/20150721070908_create_products.rb
+1
-1
db/migrate/20150804082910_change_limit.rb
+14
-0
db/schema.rb
+4
-0
test/fixtures/carts.yml
+4
-4
No files found.
app/controllers/admins/users_controller.rb
View file @
5e245ce1
class
Admins
::
UsersController
<
ApplicationController
class
Admins
::
UsersController
<
ApplicationController
<<<<<<<
HEAD
before_action
:authenticate_admin!
before_action
:authenticate_admin!
=======
>>>>>>>
f67de3d08984550ced73d3a059652089858ce582
def
show
def
show
@users
=
User
.
paginate
(
page:
params
[
:page
]).
per_page
(
25
)
@users
=
User
.
paginate
(
page:
params
[
:page
]).
per_page
(
25
)
end
end
<<<<<<<
HEAD
def
delete
def
delete
@user
=
User
.
find
(
params
[
:id
])
@user
=
User
.
find
(
params
[
:id
])
@user
.
destroy
@user
.
destroy
redirect_to
:back
redirect_to
:back
end
end
=======
>>>>>>>
f67de3d08984550ced73d3a059652089858ce582
end
end
app/controllers/carts_controller.rb
View file @
5e245ce1
...
@@ -18,7 +18,17 @@ class CartsController < ApplicationController
...
@@ -18,7 +18,17 @@ class CartsController < ApplicationController
@new_cart
=
Cart
.
new
(
fullname:
params
[
:cart
][
:fullname
],
email:
params
[
:cart
][
:email
],
@new_cart
=
Cart
.
new
(
fullname:
params
[
:cart
][
:fullname
],
email:
params
[
:cart
][
:email
],
address:
params
[
:cart
][
:address
],
phone:
params
[
:cart
][
:phone
],
address:
params
[
:cart
][
:address
],
phone:
params
[
:cart
][
:phone
],
total_price:
calculate_total_price
,
status:
"new cart"
,
user_id:
cart_user_id
)
total_price:
calculate_total_price
,
status:
"new cart"
,
user_id:
cart_user_id
)
<<<<<<<
HEAD
if
@new_cart
.
save
if
@new_cart
.
save
=======
#new_cart.total_price = calculate_total_price
#new_cart.status = "new cart"
#if user_signed_in?
# new_cart.user_id = current_user.id
#end
if
@new_cart
.
save
#if !new_cart.id.nil?
>>>>>>>
f67de3d08984550ced73d3a059652089858ce582
session
[
:cart
].
each
do
|
id
,
quantity
|
session
[
:cart
].
each
do
|
id
,
quantity
|
cart_product
=
CartProduct
.
new
cart_product
=
CartProduct
.
new
cart_product
.
cart_id
=
@new_cart
.
id
cart_product
.
cart_id
=
@new_cart
.
id
...
...
app/controllers/categories_controller.rb
View file @
5e245ce1
...
@@ -7,8 +7,11 @@ class CategoriesController < ApplicationController
...
@@ -7,8 +7,11 @@ class CategoriesController < ApplicationController
rescue
rescue
redirect_to
root_path
redirect_to
root_path
end
end
<<<<<<<
HEAD
end
end
def
index
def
index
redirect_to
root_path
redirect_to
root_path
=======
>>>>>>>
f67de3d08984550ced73d3a059652089858ce582
end
end
end
end
\ No newline at end of file
app/models/product.rb
View file @
5e245ce1
...
@@ -5,4 +5,8 @@ class Product < ActiveRecord::Base
...
@@ -5,4 +5,8 @@ class Product < ActiveRecord::Base
validates
:name
,
:image
,
presence:
true
,
length:
{
maximum:
1000
}
validates
:name
,
:image
,
presence:
true
,
length:
{
maximum:
1000
}
validates
:description
,
length:
{
maximum:
65535
}
validates
:description
,
length:
{
maximum:
65535
}
validates
:price
,
:numericality
=>
{
:greater_than_or_equal_to
=>
0
,
:less_than_or_equal_to
=>
99999999
}
validates
:price
,
:numericality
=>
{
:greater_than_or_equal_to
=>
0
,
:less_than_or_equal_to
=>
99999999
}
<<<<<<<
HEAD
=======
validates
:page
,
:numericality
=>
{
:greater_than_or_equal_to
=>
0
}
>>>>>>>
f67de3d08984550ced73d3a059652089858ce582
end
end
app/views/admins/products/show.html.erb
View file @
5e245ce1
<%
if
admin_signed_in?
%>
<%
if
admin_signed_in?
%>
<
<<<<<<
HEAD
<
div
class=
"span12"
>
<
div
class=
"span12"
>
<h2>
Products
</h2>
<h2>
Products
</h2>
=======
<div
class=
"span12"
>
<h2>
Products
</h2>
<%=
link_to
"Insert Product"
,
insert_product_path
,
class:
"pull-right"
%>
>>>>>>> f67de3d08984550ced73d3a059652089858ce582
<table
class=
"table table-striped table-hover"
>
<table
class=
"table table-striped table-hover"
>
<thead>
<thead>
<tr>
<tr>
...
...
config/routes.rb
View file @
5e245ce1
VenShop
::
Application
.
routes
.
draw
do
VenShop
::
Application
.
routes
.
draw
do
<<<<<<<
HEAD
=======
namespace
:admins
do
get
'users/new'
end
>>>>>>>
f67de3d08984550ced73d3a059652089858ce582
devise_for
:users
devise_for
:users
devise_for
:admins
devise_for
:admins
namespace
:users
do
namespace
:users
do
...
...
db/migrate/20150721070908_create_products.rb
View file @
5e245ce1
...
@@ -4,7 +4,7 @@ class CreateProducts < ActiveRecord::Migration
...
@@ -4,7 +4,7 @@ class CreateProducts < ActiveRecord::Migration
t
.
string
:name
t
.
string
:name
t
.
string
:image
t
.
string
:image
t
.
integer
:price
t
.
integer
:price
t
.
string
:description
,
limit:
65535
t
.
string
:description
t
.
integer
:category_id
t
.
integer
:category_id
t
.
timestamps
null:
false
t
.
timestamps
null:
false
...
...
db/migrate/20150804082910_change_limit.rb
0 → 100644
View file @
5e245ce1
class
ChangeLimit
<
ActiveRecord
::
Migration
def
change
change_column
:products
,
:price
,
:integer
,
:limit
=>
5
change_column
:products
,
:description
,
:string
,
:limit
=>
20000
change_column
:cart_products
,
:cart_id
,
:integer
,
:limit
=>
5
change_column
:cart_products
,
:product_id
,
:integer
,
:limit
=>
5
change_column
:cart_products
,
:quantity
,
:integer
,
:limit
=>
5
change_column
:cart_products
,
:price
,
:integer
,
:limit
=>
5
change_column
:carts
,
:user_id
,
:integer
,
:limit
=>
5
change_column
:carts
,
:total_price
,
:integer
,
:limit
=>
5
change_column
:products
,
:name
,
:string
,
:limit
=>
1000
change_column
:products
,
:category_id
,
:integer
,
:limit
=>
5
end
end
db/schema.rb
View file @
5e245ce1
...
@@ -11,7 +11,11 @@
...
@@ -11,7 +11,11 @@
#
#
# It's strongly recommended that you check this file into your version control system.
# It's strongly recommended that you check this file into your version control system.
<<<<<<<
HEAD
ActiveRecord
::
Schema
.
define
(
version:
20150811014432
)
do
ActiveRecord
::
Schema
.
define
(
version:
20150811014432
)
do
=======
ActiveRecord
::
Schema
.
define
(
version:
20150804082910
)
do
>>>>>>>
f67de3d08984550ced73d3a059652089858ce582
create_table
"admins"
,
force: :cascade
do
|
t
|
create_table
"admins"
,
force: :cascade
do
|
t
|
t
.
string
"email"
,
limit:
255
,
default:
""
,
null:
false
t
.
string
"email"
,
limit:
255
,
default:
""
,
null:
false
...
...
test/fixtures/carts.yml
View file @
5e245ce1
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one
:
one
:
U
ser_id
:
1
u
ser_id
:
1
total_price
:
1
total_price
:
1
status
:
MyString
status
:
MyString
fullname
:
MyString
fullname
:
MyString
phone
:
1
phone
:
MyString
address
:
MyString
address
:
MyString
email
:
MyString
email
:
MyString
two
:
two
:
U
ser_id
:
1
u
ser_id
:
1
total_price
:
1
total_price
:
1
status
:
MyString
status
:
MyString
fullname
:
MyString
fullname
:
MyString
phone
:
1
phone
:
MyString
address
:
MyString
address
:
MyString
email
:
MyString
email
:
MyString
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