Commit 7099ab3b by Trong Huu Nguyen

Merge branch 'dhp_apply_bootstrap' into 'development'

[REVIEW] Apply bootstrap

See merge request !1
parents 13166288 30bbcb60
...@@ -30,6 +30,17 @@ gem 'jbuilder', '~> 2.5' ...@@ -30,6 +30,17 @@ gem 'jbuilder', '~> 2.5'
# Use ActiveModel has_secure_password # Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7' # gem 'bcrypt', '~> 3.1.7'
# Provides a simple and extremely flexible way to upload files from Ruby applications
gem 'carrierwave', '~> 1.0'
# A ruby wrapper for ImageMagick or GraphicsMagick command line.
gem 'mini_magick'
# bootstrap-sass is a Sass-powered version of Bootstrap 3
gem 'bootstrap-sass', '~> 3.3.6'
# Faker, a port of Data::Faker from Perl, is used to easily generate fake data: names, addresses, phone numbers, etc.
gem 'faker', '~> 1.6', '>= 1.6.3'
# Kaminari is a Scope & Engine based, clean, powerful, agnostic, customizable and sophisticated paginator for Rails 4+
gem 'kaminari', '~> 1.0', '>= 1.0.1'
# Use Capistrano for deployment # Use Capistrano for deployment
# gem 'capistrano-rails', group: :development # gem 'capistrano-rails', group: :development
...@@ -51,4 +62,4 @@ group :development do ...@@ -51,4 +62,4 @@ group :development do
end end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
\ No newline at end of file
...@@ -41,7 +41,12 @@ GEM ...@@ -41,7 +41,12 @@ GEM
addressable (2.5.1) addressable (2.5.1)
public_suffix (~> 2.0, >= 2.0.2) public_suffix (~> 2.0, >= 2.0.2)
arel (8.0.0) arel (8.0.0)
autoprefixer-rails (7.1.1)
execjs
bindex (0.5.0) bindex (0.5.0)
bootstrap-sass (3.3.6)
autoprefixer-rails (>= 5.2.1)
sass (>= 3.3.4)
builder (3.2.3) builder (3.2.3)
byebug (9.0.6) byebug (9.0.6)
capybara (2.14.0) capybara (2.14.0)
...@@ -51,6 +56,10 @@ GEM ...@@ -51,6 +56,10 @@ GEM
rack (>= 1.0.0) rack (>= 1.0.0)
rack-test (>= 0.5.4) rack-test (>= 0.5.4)
xpath (~> 2.0) xpath (~> 2.0)
carrierwave (1.1.0)
activemodel (>= 4.0.0)
activesupport (>= 4.0.0)
mime-types (>= 1.16)
childprocess (0.7.0) childprocess (0.7.0)
ffi (~> 1.0, >= 1.0.11) ffi (~> 1.0, >= 1.0.11)
coffee-rails (4.2.2) coffee-rails (4.2.2)
...@@ -63,6 +72,8 @@ GEM ...@@ -63,6 +72,8 @@ GEM
concurrent-ruby (1.0.5) concurrent-ruby (1.0.5)
erubi (1.6.0) erubi (1.6.0)
execjs (2.7.0) execjs (2.7.0)
faker (1.6.6)
i18n (~> 0.5)
ffi (1.9.18) ffi (1.9.18)
globalid (0.4.0) globalid (0.4.0)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
...@@ -70,6 +81,18 @@ GEM ...@@ -70,6 +81,18 @@ GEM
jbuilder (2.7.0) jbuilder (2.7.0)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
multi_json (>= 1.2) multi_json (>= 1.2)
kaminari (1.0.1)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.0.1)
kaminari-activerecord (= 1.0.1)
kaminari-core (= 1.0.1)
kaminari-actionview (1.0.1)
actionview
kaminari-core (= 1.0.1)
kaminari-activerecord (1.0.1)
activerecord
kaminari-core (= 1.0.1)
kaminari-core (1.0.1)
listen (3.1.5) listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4) rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7) rb-inotify (~> 0.9, >= 0.9.7)
...@@ -82,6 +105,7 @@ GEM ...@@ -82,6 +105,7 @@ GEM
mime-types (3.1) mime-types (3.1)
mime-types-data (~> 3.2015) mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521) mime-types-data (3.2016.0521)
mini_magick (4.5.1)
mini_portile2 (2.2.0) mini_portile2 (2.2.0)
minitest (5.10.2) minitest (5.10.2)
multi_json (1.12.1) multi_json (1.12.1)
...@@ -172,11 +196,16 @@ PLATFORMS ...@@ -172,11 +196,16 @@ PLATFORMS
ruby ruby
DEPENDENCIES DEPENDENCIES
bootstrap-sass (~> 3.3.6)
byebug byebug
capybara (~> 2.13) capybara (~> 2.13)
carrierwave (~> 1.0)
coffee-rails (~> 4.2) coffee-rails (~> 4.2)
faker (~> 1.6, >= 1.6.3)
jbuilder (~> 2.5) jbuilder (~> 2.5)
kaminari (~> 1.0, >= 1.0.1)
listen (>= 3.0.5, < 3.2) listen (>= 3.0.5, < 3.2)
mini_magick
mysql2 (>= 0.3.18, < 0.5) mysql2 (>= 0.3.18, < 0.5)
puma (~> 3.7) puma (~> 3.7)
rails (~> 5.1.1) rails (~> 5.1.1)
......
// "bootstrap-sprockets" must be imported before "bootstrap" and "bootstrap/variables"
@import "bootstrap-sprockets";
@import "bootstrap";
\ No newline at end of file
/******************************************
1. Common styles
******************************************/
body {
background: #f7f7f7;
color: #333333;
font-family: 'Poppins', Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: 400;
line-height: 15px;
text-align: left;
letter-spacing: 0.8px;
}
* {
margin: 0;
padding: 0
}
img {
border: 0;
max-width: 100%
}
a {
color: #333333;
text-decoration: none;
transition: 0.5s all ease
}
a:hover {
text-decoration: none;
color: #ffd401
}
a:focus {
outline: 0;
text-decoration: none;
color: #666
}
:focus {
outline: none;
}
h1, h2, h3, h4, h5, h6 {
margin: 0 0 5px;
line-height: 1.35;
color: #333333
}
h1 {
font-weight: normal
}
h2 {
font-weight: normal;
margin-bottom: 15px
}
h3 {
font-weight: 500
}
h4 {
font-weight: 500
}
h5 {
font-weight: 500
}
h6 {
font-weight: 500
}
form {
display: inline
}
fieldset {
border: 0
}
legend {
display: none
}
table {
border: 0;
border-spacing: 0;
empty-cells: show;
font-size: 100%; background-color:#fff;
}
caption, th, td {
vertical-align: top;
text-align: left;
font-weight: normal;background-color:#fff;
}
thead tr th {
font-weight: bold;
text-transform: uppercase;
font-size: 12px
}
p {
margin: 0 0 10px
}
strong {
font-weight: 600
}
address {
font-style: normal;
line-height: 1.35
}
cite {
font-style: normal
}
q, blockquote {
quotes: none
}
q:before, q:after {
content: ''
}
small, big {
font-size: 1em
}
ul, ol {
padding: 0;
margin: 0 0 10px 25px
}
ul ul, ul ol, ol ol, ol ul {
margin-bottom: 0
}
ul.unstyled, ol.unstyled {
margin-left: 0;
list-style: none
}
ul.inline, ol.inline {
margin-left: 0;
list-style: none
}
ul.inline>li, ol.inline>li {
display: inline-block;
*display:inline;
padding-right: 5px;
padding-left: 5px;
*zoom:1
}
ul ul, ol ul {
list-style-type: circle
}
.hidden {
display: block !important;
border: 0 !important;
margin: 0 !important;
padding: 0 !important;
font-size: 0 !important;
line-height: 0 !important;
width: 0 !important;
height: 0 !important;
overflow: hidden !important
}
.nobr {
white-space: nowrap !important
}
.wrap {
white-space: normal !important
}
.a-left {
text-align: left !important
}
.a-center {
text-align: center !important
}
.a-right {
text-align: right !important
}
.v-top {
vertical-align: top
}
.v-middle {
vertical-align: middle
}
.f-left, .left {
float: left !important
}
.f-right, .right {
float: right !important
}
.f-none {
float: none !important
}
.f-fix {
float: left;
width: 100%
}
.no-display {
display: none
}
.no-margin {
margin: 0 !important
}
.no-padding {
padding: 0 !important
}
.no-bg {
background: none !important
}
small {
font-size: 85%;
font-weight: normal;
text-transform: lowercase;
color: #999999
}
input:focus {
outline: none
}
.page-title h1, .page-title h2 {
color: #333333;
font-size: 22px;
font-weight: 600;
text-transform: uppercase;
margin-top: 0px;
line-height: normal;
margin-bottom: 5px;
letter-spacing: 0.5px;
}
@media (max-width:767px) {
.page-title h1, .page-title h2 {
font-size: 26px
}
}
/******************************************
9. product hover
******************************************/
.product-item {
list-style: none;
}
.product-item .product-thumb {
position: relative;
}
.product-item .pr-info-area {
position: absolute;
bottom: 15px;
text-align: center;
width: 100%;
}
.product-item .pr-info-area a {
margin: 0 8px;
}
.product-item .has-hover-img .hover-img {
position: absolute;
right: 0;
left: 0;
top: 0;
width: 100%;
transition: opacity 0.5s ease-in-out 0s;
-moz-transition: opacity 0.5s ease-in-out 0s;
-webkit-transition: opacity 0.5s ease-in-out 0s;
backface-visibility: hidden;
-moz-backface-visibility: hidden;
-webkit-backface-visibility: hidden;
opacity: 0;
}
.product-item .has-hover-img:hover .hover-img {
opacity: 1;
}
.product-item .wishlist, .product-item .compare, .product-item .quick-view {
position: relative;
text-align: center;
line-height: 35px;
margin-bottom: 10px;
background-color: #fff;
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
opacity: 0;
filter: alpha(opacity=0);
color: #222;
display: inline-block;
transform: rotate(-45deg);
-webkit-transform: rotate(-45deg);
width: 35px;
height: 35px;
margin: 0 5px;
}
.product-item:hover .wishlist, .product-item:hover .compare, .product-item:hover .quick-view {
opacity: 1;
transform: rotate(-45deg);
-webkit-transform: rotate(-45deg);
}
.product-item .wishlist i, .product-item .compare i, .product-item .quick-view i {
transform: rotate(45deg);
-webkit-transform: rotate(45deg);
}
.product-item .wishlist i span, .product-item .compare i span, .product-item .quick-view i span {
display: none;
}
.product-item .wishlist:hover, .product-item .compare:hover, .product-item .quick-view:hover {
color: #fff;
background-color: #ffd401;
}
.product-item .item-inner:hover:hover .animate1 {
-webkit-animation-name: flip;
animation-name: flip;
}
.product-item .item-inner:hover:hover .animate2 {
-webkit-animation-name: bounce;
animation-name: bounce;
}
.product-item .item-inner:hover:hover .animate3 {
-webkit-animation-name: rubberBand;
animation-name: rubberBand;
}
.product-item .item-inner:hover:hover .animate4 {
-webkit-animation-name: lightSpeedIn;
animation-name: lightSpeedIn;
}
.product-item .item-inner:hover .animate5 {
-webkit-animation-name: rotateIn;
animation-name: rotateIn;
}
.product-item .item-inner:hover .animate6 {
-webkit-animation-name: zoomInUp;
animation-name: zoomInUp;
}
.add-to-cart-mt {
background: #f8f8f8;
border: 0 none;
bottom: 0;
text-align: center;
text-transform: uppercase;
transition: all .5s ease-out 0s;
padding: 0px 15px 0px 0px;
color: #333333;
border: 1px #eee solid;
}
.add-to-cart-mt i {
position: relative;
text-align: center;
line-height: 35px;
background-color: #ffd401;
filter: alpha(opacity=0);
color: #fff;
display: inline-block;
width: 35px;
height: 35px;
}
.add-to-cart-mt:hover {
background: #333333;
color: #fff;
}
.add-to-cart-mt span {
margin-left: 10px
}
.pr-button .mt-button {
width: 33.3%;
float: left;
text-align: center;
border-right: 1px solid
}
.product-item .item-inner .item-info {
text-align: center;
padding-top: 12px;
}
.product-item .item-inner .item-info .pro-action {
margin-top: 10px;
}
.product-item .item-inner .item-info .item-title {
font-size: 12px;
margin-bottom: 6px;
font-weight: 400;
}
@media (max-width:479px) {
.product-item .item-inner .item-info .item-title {
font-size: 12px;
padding: 0px 10px
}
}
.product-item .item-inner .item-info .item-title a {
display: inherit;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
padding: 0 10px;
font-size: 12px;
font-weight: 500;
text-transform: none;
}
.product-item .item-inner {
position: relative;
overflow: hidden; background-color:#fff; padding-bottom:20px;
}
.product-item {
margin: 0 12px
}
.product-item .item-inner .item-info .item-title a:hover {
color: #ffd401;
}
@media (max-width:479px) {
.home-tab .product-item {
margin: 0 8px
}
}
#best-sale-slider.product-flexslider {
margin: 20px -12px
}
.best-sale-pro .slider-items-products .owl-buttons .owl-prev {
top: 15%
}
.best-sale-pro .slider-items-products .owl-buttons .owl-next {
top: 15%
}
/******************************************
21. Toolbar
******************************************/
.pagination-area {
background: rgba(0,0,0,0) none repeat scroll 0 0;
border-top: 1px solid #eee;
margin: 10px 0 0;
padding-top: 20px;
text-align: center;
display: inline-block;
width: 100%
}
.pagination-area ul {
margin-bottom: 0px
}
.pagination-area ul li {
background: #f5f5f5;
color: #393939;
display: inline-block;
font-weight: 600;
line-height: 30px;
margin: 0 0 0 5px;
border-radius: 4px
}
.pagination-area ul li a {
border: 1px solid #e0e0e0;
color: #363636;
display: block;
font-weight: 600;
text-decoration: none;
border-radius: 4px;
transition: all .4s ease-out .2s
}
.pagination-area ul li a:hover {
background: #333333;
border: 1px solid #333333;
color: #fff;
}
.pagination-area ul li a.active {
background: #ffd401;
border: 1px solid #ffd401;
border-radius: 4px;
color: #fff;
transition: all .4s ease-out .2s
}
/******************************************
26. products grid
******************************************/
.shop-inner {
padding: 20px 0;
margin-bottom: 30px;
}
.products-grid {
margin: 0;
list-style: none
}
ul.products-grid {
padding: 0;
margin: 0
}
.products-grid .item {
margin-top: 30px;
padding: 0px
}
.products-grid .product-item img {
width: 100%;
}
@media (max-width:479px) {
.product-grid-area .products-grid .item {
width: 80%;
float: none;
margin: 15px auto 15px
}
}
.col-main .product-grid-area .products-grid {
margin-left: -12px;
margin-right: -12px
}
/******************************************
27. products list
******************************************/
.products-list h2 {
font-size: 16px;
font-weight: bold;
text-align: left;
line-height: normal;
margin-bottom: 8px;
}
ul.products-list {
margin: auto;
}
.products-list button.cart-button {
color: #fff;
}
.products-list .item {
padding: 18px;
overflow: hidden;
margin: 15px 0 30px !important;
list-style: none; background-color:#fff;
}
.products-list .rating {
display: inline-block;
margin-right: 6px
}
.product-item .rating .fa.fa-star,
.jtv-category-area .jtv-product-content .fa.fa-star,
.products-list .rating .fa.fa-star,
.product-view-area .product-details-area .ratings .fa.fa-star { color:#ffd401;}
.product-item .rating .fa.fa-star-o,
.product-item .rating .fa.fa-star-half,
.jtv-category-area .jtv-product-content .fa.fa-star-o,
.jtv-category-area .jtv-product-content .fa.fa-star-half,
.products-list .rating .fa.fa-star-o,
.product-view-area .product-details-area .ratings .fa.fa-star-o{ color:#ccc;}
.products-list .rating-links {
display: inline-block;
margin-bottom: 4px
}
.products-list .rating-links a {
font-size: 11px;
}
.products-list .item h3 {
font-weight: normal;
color: #353535;
padding-bottom: 2px
}
.products-list .item h3 a {
font-weight: normal;
font-size: 12px;
color: #407CBF;
text-decoration: none
}
.products-list .item h3 a:hover {
font-weight: normal;
font-size: 12px;
color: #333333;
text-decoration: underline
}
.products-list .product-img {
overflow: hidden;
position: relative;
padding-left: 0;
width: 30%;
float: left;
}
.products-list .product-img img {
width: 100%
}
.products-list .product-shop {
width: 67%;
float: right;
}
.products-list .product-shop .desc {
font-size: 12px;
margin-bottom: 15px;
margin-top: 5px;
color: #666
}
.products-list .product-shop p {
font-size: 12px;
color: #666;
line-height: 1.5em
}
.products-list .product-shop p.old-price {
margin-right: 4px
}
.products-list .product-shop .price-box {
margin: 5px 0 10px;
border-top: 1px solid #eee;
padding-top: 12px;
}
.products-list .desc a.link-learn {
font-size: 12px;
font-weight: bold;
margin-top: 5px;
color: #ffd401
}
.products-list .product-shop button.button span {
padding: 1px 0 0 10px;
text-transform: uppercase
}
.products-list .product-shop .actions ul {
display: inline-block;
float: right;
margin-top: 8px
}
.products-list .product-shop .actions ul li {
margin-right: 20px;
display: inline-block
}
.products-list .product-shop .actions ul li a {
text-transform: uppercase;
font-size: 12px
}
.products-list .product-shop .actions ul li:last-child a {
border-left: 1px solid #e5e5e5;
padding-left: 21px
}
.products-list .product-shop .actions ul li:last-child {
margin-right: 0px
}
.products-list .product-shop .actions ul li span {
margin-left: 5px
}
/******************************************
28. price box
******************************************/
.price {
font-size: 12px;
color: #000;
white-space: nowrap !important;
}
.price-box {
margin: 8px 0 2px
}
.regular-price {
display: inline
}
.regular-price .price {
font-weight: bold;
font-size: 16px;
color: #000
}
.block .regular-price, .block .regular-price .price {
color: #333333
}
.price-box .price-from .price {
font-weight: 600;
font-size: 12px;
color: #333333
}
.price-box .price-to .price {
font-weight: 600;
font-size: 12px;
color: #333333
}
.price-box .minimal-price .price {
font-weight: 600;
font-size: 12px;
color: #333333
}
.old-price .price-label {
white-space: nowrap;
color: #999;
display: none
}
.old-price {
display: inline;
margin-right: 15px
}
.old-price .price-label {
color: #777777;
display: none;
white-space: nowrap
}
.old-price .price {
color: #777777!important;
font-size: 14px;
font-weight: normal;
text-decoration: line-through;
margin-left: 6px
}
.special-price {
margin: 0;
padding: 3px 0;
display: inline
}
.special-price .price-label {
color: #666;
display: none;
font-size: 12px;
font-weight: 400;
white-space: nowrap
}
.special-price .price {
font-size: 16px;
color: #000;
font-weight: bold
}
.special-price .price-label {
font-size: 12px;
font-weight: 600;
white-space: nowrap;
color: #666;
display: none
}
.minimal-price {
margin: 0
}
.minimal-price .price-label {
white-space: nowrap
}
.minimal-price-link {
display: inline
}
class CategoriesController < ApplicationController
def show
@category = Category.find(params[:id])
@products = @category.products.take(6)
end
end
\ No newline at end of file
class ProductsController < ApplicationController
end
\ No newline at end of file
class StaticPagesController < ApplicationController
def index
@latest_products = Product.page(params[:page]).per(10)
# @TODO: Get recommended products
@recommended_products = Product.last(6)
end
end
\ No newline at end of file
module ProductsHelper
def get_product_thumbnail(product, thumbnail_width, thumbnail_height)
product.image_url ||
"product/placeholder_#{thumbnail_width}x#{thumbnail_height}"
end
end
\ No newline at end of file
class Category < ApplicationRecord
has_many :products, dependent: :destroy
end
\ No newline at end of file
class Product < ApplicationRecord
belongs_to :category
end
\ No newline at end of file
<div class="row">
<div class="col-md-9 col-md-push-3">
<div class="category-header">
<h2><%= @category.title %></h2>
</div>
<div class="shop-row">
<div class="shop-container">
<ul class="products-list">
<%= render @products %>
</ul>
</div>
</div>
</div>
<!-- End .col-md-9 -->
<div class="col-md-3 col-md-pull-9 sidebar">
<%= render 'shared/sidebar' %>
</div>
</div>
<!-- End .row -->
\ No newline at end of file
<li class="first">
<%= link_to_unless current_page.first?, t('views.pagination.first').html_safe, url, remote: remote %>
</li>
<li class="dots">
<a href="#"><%= t('views.pagination.truncate').html_safe %></a>
</li>
<li class="last">
<%= link_to_unless current_page.last?, t('views.pagination.last').html_safe, url, remote: remote %>
</li>
<li class="next">
<%= link_to_unless current_page.last?, t('views.pagination.next').html_safe, url, rel: 'next', remote: remote %>
</li>
<li class="page<%= ' active' if page.current? %>">
<%= link_to page, url, opts = {:remote => remote, :class => page.current? ? 'active' : 'page-link', :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil} %>
</li>
<%= paginator.render do -%>
<nav aria-label="Page Navigation">
<ul class="pagination">
<%= first_page_tag unless current_page.first? %>
<%= prev_page_tag unless current_page.first? %>
<% each_page do |page| -%>
<% if page.display_tag? -%>
<%= page_tag page %>
<% elsif !page.was_truncated? -%>
<%= gap_tag %>
<% end -%>
<% end -%>
<% unless current_page.out_of_range? %>
<%= next_page_tag unless current_page.last? %>
<%= last_page_tag unless current_page.last? %>
<% end %>
</ul>
</nav>
<% end -%>
<li class="prev">
<%= link_to_unless current_page.first?, t('views.pagination.previous').html_safe, url, rel: 'prev', remote: remote %>
</li>
...@@ -9,6 +9,12 @@ ...@@ -9,6 +9,12 @@
</head> </head>
<body> <body>
<%= yield %> <div id="main-container col2-left-layout">
<div class="container">
<%= yield %>
</div>
<!-- End .container -->
</div>
<!-- End .main-container -->
</body> </body>
</html> </html>
<li class="item">
<div class="product-img">
<a href="#">
<figure>
<%= image_tag(get_product_thumbnail(product, 170, 204), class: "small-image") %>
</figure>
</a>
</div>
<div class="product-shop">
<h2 class="product-name"><%= product.title %></h2>
<div class="price-box">
<div class="special-price">
<span class="price"><%= number_to_currency(product.price) %></span>
</div>
</div>
<div class="desc std">
<%= simple_format(product.description) %>
</div>
</div>
</li>
\ No newline at end of file
<ul class="products-grid">
<% @recommended_products.each do |product| %>
<li class="item col-lg-4 col-md-4 col-sm-6 col-xs-6 ">
<div class="product-item">
<div class="item-inner">
<div class="product-thumb">
<figure>
<a href="#">
<%= image_tag(get_product_thumbnail(product, 170, 204)) %>
</a>
</figure>
</div>
<div class="item-info">
<div class="info-inner">
<div class="item-title">
<%= link_to product.title, "#" %>
</div>
<div class="item-content">
<div class="item-price">
<div class="price-box">
<div class="regular-price">
<span class="price"><%= number_to_currency(product.price) %></span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</li>
<% end %>
</ul>
\ No newline at end of file
<div class="row">
<div class="col-main col-sm-9 col-xs-12 col-sm-push-3">
<div class="shop-inner">
<div class="page-title">
<h1>Recommended Items</h1>
</div>
<div class="product-grid-area">
<%= render 'products/recommended' %>
</div>
<div class="page-title">
<h1>Newest Items</h1>
</div>
<div class="product-list-area">
<ul id="products-list" class="products-list">
<%= render @latest_products %>
</ul>
</div>
<div class="pagination-area">
<%= paginate @latest_products %>
</div>
</div>
</div>
<aside class="sidebar col-sm-3 col-xs-12 col-sm-pull-9">
<%= render 'shared/sidebar' %>
</aside>
</div>
...@@ -12,10 +12,8 @@ ...@@ -12,10 +12,8 @@
default: &default default: &default
adapter: mysql2 adapter: mysql2
encoding: utf8 encoding: utf8
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
username: root username: root
password: password: 123123
socket: /var/run/mysqld/mysqld.sock
development: development:
<<: *default <<: *default
......
Rails.application.routes.draw do Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root 'static_pages#index'
resources :categories
end end
class CreateCategories < ActiveRecord::Migration[5.1]
def change
create_table :categories do |t|
t.string :title
t.text :description
end
end
end
class CreateProducts < ActiveRecord::Migration[5.1]
def change
create_table :products do |t|
t.string :title
t.text :description
t.text :sku
t.decimal :price, precision: 8, scale: 2
t.references :category, index: true
t.timestamps
end
end
end
class AddImageColumnsToProducts < ActiveRecord::Migration[5.1]
def change
add_column :products, :image_url, :string
end
end
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170606064132) do
create_table "categories", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "title"
t.text "description"
end
create_table "products", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
t.string "title"
t.text "description"
t.text "sku"
t.decimal "price", precision: 8, scale: 2
t.bigint "category_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "image_url"
t.index ["category_id"], name: "index_products_on_category_id"
end
add_foreign_key "products", "categories"
end
...@@ -5,3 +5,28 @@ ...@@ -5,3 +5,28 @@
# #
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Character.create(name: 'Luke', movie: movies.first) # Character.create(name: 'Luke', movie: movies.first)
# Delete all categories
Category.destroy_all
# Create Product Categories
4.times do |n|
title = "Category #{n}"
desc = Faker::Lorem.paragraphs
Category.create!(title: title, description: desc)
end
# Create Products
categories = Category.all
80.times do
categories.each do |cat|
title = Faker::Commerce.product_name
desc = Faker::Lorem.paragraphs
sku = "u-#{rand(1..999)}"
price = Faker::Commerce.price
cat.products.create!(title: title,
description: desc,
sku: sku,
price: price)
end
end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment