File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -50,21 +50,21 @@ def create
5050
5151 def destroy
5252 @order = Order . find ( params [ :id ] )
53- flash [ :info ] = 'Found product to destroy'
54- # @order.destroy
55- # respond_to do |format|
56- # format.html { redirect_to orders_path, notice: 'Order was successfully destroyed.' }
57- # format.json { head :no_content }
58- # flash[:info] = 'Order was successfully destroyed.'
59- # end
53+ @order . destroy
54+ respond_to do |format |
55+ format . html { redirect_to orders_path }
56+ format . json { head :no_content }
57+ flash [ :info ] = 'Order was successfully destroyed.'
58+ end
6059 end
6160
6261 def edit
6362 @order = Order . find ( params [ :id ] )
6463 end
6564
6665 def update
67- @order = Order . update ( order_params )
66+ @order = Order . find ( params [ :id ] )
67+ @order . update ( order_params )
6868 redirect_to orders_path
6969 end
7070
Original file line number Diff line number Diff line change 11class Order < ApplicationRecord
22 has_many :line_items , dependent : :destroy
3+ belongs_to :user
34
45 # LOGIC
56 def sub_total
Original file line number Diff line number Diff line change 11class User < ApplicationRecord
22 has_many :orders , dependent : :destroy
33 has_many :microposts , dependent : :destroy
4+ has_many :order , dependent : :destroy
45 attr_accessor :remember_token , :activation_token , :reset_token
56 before_save { email . downcase! }
67 # before_save :downcase_email
Original file line number Diff line number Diff line change 3939 |
4040 < i class ="glyphicon glyphicon-eye-open " style ="color:firebrick "> </ i >
4141 Orders
42- < span class ="badge badge-pill badge-warning "> <%= @current_user . orders . count %> </ span >
42+ < span class ="badge badge-pill badge-warning ">
43+ (<%= @current_user . orders . count %> ) Admin / (<%= Order . count %> ) Total
44+ </ span >
4345 < b class ="caret "> </ b >
4446 <% end %>
4547
Original file line number Diff line number Diff line change 11< div class ="center jumbotron ">
22 < h2 >
33 <% if params [ :search ] . blank? %>
4- All Orders (<%= @orders . count %> )
4+
5+ <% if current_user . admin? %>
6+ ADMIN --- All Orders (<%= @orders . count %> )
7+ <% else %>
8+ USER --- All Orders (<%= @current_user . orders . count %> )
9+ <% end%>
510 <% else %>
611 Found => [
712 <%= pluralize ( @orders . count , " ] Order" ) %>
You can’t perform that action at this time.
0 commit comments