<%= t ".digital_electronic" %>
+-
+ <%= render @products %>
+
-
+ <%== pagy_bootstrap_nav(@pagy) %>
+
diff --git a/app/assets/images/products/digital_20.jpg b/app/assets/images/products/digital_20.jpg new file mode 100644 index 0000000..e8e2908 Binary files /dev/null and b/app/assets/images/products/digital_20.jpg differ diff --git a/app/assets/images/shop-banner.jpg b/app/assets/images/shop-banner.jpg new file mode 100644 index 0000000..98d77bc Binary files /dev/null and b/app/assets/images/shop-banner.jpg differ diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb new file mode 100644 index 0000000..32a6960 --- /dev/null +++ b/app/controllers/products_controller.rb @@ -0,0 +1,8 @@ +class ProductsController < ApplicationController + def index + @pagy, @products = pagy Product.sort_by_price, + items: Settings.length.per_page_12 + end + + def show; end +end diff --git a/app/helpers/products_helper.rb b/app/helpers/products_helper.rb new file mode 100644 index 0000000..ab5c42b --- /dev/null +++ b/app/helpers/products_helper.rb @@ -0,0 +1,2 @@ +module ProductsHelper +end diff --git a/app/models/product.rb b/app/models/product.rb index ee0d335..8c60c8e 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -2,4 +2,5 @@ class Product < ApplicationRecord belongs_to :category has_many :order_details, dependent: :destroy has_many :comments, dependent: :destroy + scope :sort_by_price, ->{order :price} end diff --git a/app/views/products/_product.html.erb b/app/views/products/_product.html.erb new file mode 100644 index 0000000..98ba212 --- /dev/null +++ b/app/views/products/_product.html.erb @@ -0,0 +1,18 @@ +