File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,11 +2,11 @@ class OrdersController < ApplicationController
22 before_action :logged_in_user , only : %i[ index show new create ]
33
44 def index
5- # @orders = Order.all
5+ @orders = Order . all
66 if params [ :search ]
77 @orders = Order . search ( params [ :search ] ) . order ( 'created_at ASC' ) . paginate ( page : params [ :page ] , per_page : 5 )
88 else
9- @orders = Order . all . order ( 'created_at ASC' ) . paginate ( page : params [ :page ] , per_page : 5 )
9+ @orders = @orders . order ( 'created_at ASC' ) . paginate ( page : params [ :page ] , per_page : 5 )
1010 end
1111 end
1212
Original file line number Diff line number Diff line change @@ -5,11 +5,11 @@ def home
55 @feed_items = current_user . feed . paginate ( page : params [ :page ] , per_page : 6 )
66 @current_user = current_user
77 end
8- # @products = Product.all.paginate(page: params[:page], per_page: 5)
8+ @products = Product . all
99 if params [ :search ]
1010 @products = Product . search ( params [ :search ] ) . order ( 'created_at ASC' ) . paginate ( page : params [ :page ] , per_page : 5 )
1111 else
12- @products = Product . all . order ( 'created_at ASC' ) . paginate ( page : params [ :page ] , per_page : 5 )
12+ @products = @products . order ( 'created_at ASC' ) . paginate ( page : params [ :page ] , per_page : 5 )
1313 end
1414 end
1515
Original file line number Diff line number Diff line change @@ -4,11 +4,11 @@ class UsersController < ApplicationController
44 before_action :admin_user , only : :destroy
55
66 def index
7- # @users = User.where(activated: true).paginate(page: params[:page], per_page: 6)
7+ @users = User . where ( activated : true ) # .paginate(page: params[:page], per_page: 6)
88 if params [ :search ]
99 @users = User . search ( params [ :search ] ) . order ( 'created_at ASC' ) . paginate ( page : params [ :page ] , per_page : 5 )
1010 else
11- @users = User . all . order ( 'created_at ASC' ) . paginate ( page : params [ :page ] , per_page : 5 )
11+ @users = @users . order ( 'created_at ASC' ) . paginate ( page : params [ :page ] , per_page : 5 )
1212 end
1313 end
1414
Original file line number Diff line number Diff line change 11class LineItem < ApplicationRecord
22 belongs_to :product
33 belongs_to :cart
4- # belongs_to :order
4+ belongs_to :order
55
66 # LOGIC
77 def total_price
Original file line number Diff line number Diff line change 11class User < ApplicationRecord
2- has_many :orders , dependent : :destroy
3- has_many :microposts , dependent : :destroy
2+ has_many :orders , dependent : :destroy
3+ has_many :microposts , dependent : :destroy
44 attr_accessor :remember_token , :activation_token , :reset_token
55 before_save { email . downcase! }
66 # before_save :downcase_email
@@ -76,11 +76,11 @@ def password_reset_expired?
7676 # Defines a proto-feed.
7777 # See "Following users" for the full implementation.
7878 def feed
79- Micropost . where ( " user_id = ?" , id )
79+ Micropost . where ( ' user_id = ?' , id )
8080 end
8181
8282 def self . search ( search )
83- where ( 'name LIKE ?' , "%#{ search } %" )
83+ where ( 'name LIKE ? AND activated = ? ' , "%#{ search } %" , true )
8484 end
8585
8686 private
You can’t perform that action at this time.
0 commit comments