Commit c57a728d by Tan Phat Nguyen

layout show item fix, paging category max item 10

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