Module: Auth::Concerns::Shopping::DiscountControllerConcern

Extended by:
ActiveSupport::Concern
Included in:
Shopping::DiscountsController
Defined in:
app/controllers/auth/concerns/shopping/discount_controller_concern.rb

Instance Method Summary collapse

Instance Method Details

#createObject

expects the product id, resource_id is the logged in resource, and quantity



29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/auth/concerns/shopping/discount_controller_concern.rb', line 29

def create
  ##ensure that the cart item is new
 
  check_for_create(@auth_shopping_discount)
  @auth_shopping_discount = add_owner_and_signed_in_resource(@auth_shopping_discount)
   
  @auth_shopping_discount.save

  respond_with @auth_shopping_discount
end

#destroyObject

can be removed. responds with 204, and empty response body, if all is ok.



70
71
72
73
74
# File 'app/controllers/auth/concerns/shopping/discount_controller_concern.rb', line 70

def destroy
  not_found if @auth_shopping_discount.nil?
  @auth_shopping_discount.destroy
  respond_with @auth_shopping_discount
end

#indexObject

should show those cart items which do not have a parent_id. since these are the pending cart items. all remaining cart items have already been assigned to carts



62
63
64
65
# File 'app/controllers/auth/concerns/shopping/discount_controller_concern.rb', line 62

def index
  @auth_shopping_discounts = @auth_shopping_discount_class.where({:resource_id => lookup_resource.id.to_s})
  respond_with @auth_shopping_discounts
end

#initialize_varsObject



9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/auth/concerns/shopping/discount_controller_concern.rb', line 9

def initialize_vars

  instantiate_shopping_classes

 
  @auth_shopping_discount_params = permitted_params.fetch(:discount,{})
  
  @auth_shopping_discount = params[:id] ? @auth_shopping_discount_class.find(params[:id]) : @auth_shopping_discount_class.new(@auth_shopping_discount_params)

end

#showObject



53
54
55
56
57
# File 'app/controllers/auth/concerns/shopping/discount_controller_concern.rb', line 53

def show
  instantiate_shopping_classes
  @auth_shopping_discount = @auth_shopping_discount_class.find(params[:id])
  respond_with @auth_shopping_discount 
end

#updateObject



41
42
43
44
45
46
47
48
49
50
51
# File 'app/controllers/auth/concerns/shopping/discount_controller_concern.rb', line 41

def update

  check_for_update(@auth_shopping_discount)
  
  @auth_shopping_discount.assign_attributes(@auth_shopping_discount_params)
  @auth_shopping_discount = add_owner_and_signed_in_resource(@auth_shopping_discount)  

  @auth_shopping_discount.save

  respond_with @auth_shopping_discount
end