Commit c57a728d by Tan Phat Nguyen

layout show item fix, paging category max item 10

parent 6095a97a
......@@ -44,8 +44,8 @@
}
.main {
padding-right: 40px;
padding-left: 40px;
padding-right: 24px;
padding-left: 80px;
}
.main .page-header {
......@@ -81,3 +81,7 @@ h2 {
.price-col {
color: #b12704;
}
.col-sm-3 {
width: 20%;
}
\ No newline at end of file
......@@ -2,7 +2,7 @@ class Admin::ProductsController < ApplicationController
before_action :set_product, only: [:show, :edit, :update, :destroy]
def index
@products = Product.all
@products = Product.all.page(params[:page])
end
def new
......
......@@ -2,17 +2,17 @@ class Product < ActiveRecord::Base
belongs_to :category
validates :name, presence: true, length: { maximum: 50 }
validates :name, presence: true, length: { maximum: 200 }
validates :price, presence: true, numericality: true,
format: { with: /\A\d+(?:\.\d{0,2})?\z/ }
validates :description, presence: true
validate :photo_size
scope :newest, -> { order(created_at: :desc).limit(4) }
scope :newest, -> { order(created_at: :desc).limit(5) }
mount_uploader :photo, ImageUploader
paginates_per 8
paginates_per 10
private
......
......@@ -12,5 +12,6 @@
</tr>
<%= render @products %>
</table>
<%= paginate @products %>
</div>
<%= link_to 'New Product', new_admin_product_path, class: "btn btn-primary" %>
\ 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