Class: Spree::Admin::LineItemsController
- Inherits:
-
BaseController
- Object
- ApplicationController
- BaseController
- BaseController
- Spree::Admin::LineItemsController
- Defined in:
- app/controllers/spree/admin/line_items_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #load_line_item ⇒ Object
- #load_order ⇒ Object
- #new ⇒ Object
- #update ⇒ Object
Methods included from Core::ControllerHelpers
Instance Method Details
#create ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/spree/admin/line_items_controller.rb', line 10 def create variant = Variant.find(params[:line_item][:variant_id]) @line_item = @order.add_variant(variant, params[:line_item][:quantity].to_i) if @order.save respond_with(@line_item) do |format| format.html { render :partial => 'spree/admin/orders/form', :locals => { :order => @order.reload }, :layout => false } end else respond_with(@line_item) do |format| format.js { render :action => 'create', :locals => { :order => @order.reload }, :layout => false } end end end |
#destroy ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/spree/admin/line_items_controller.rb', line 25 def destroy if @line_item.destroy respond_with(@line_item) do |format| format.html { render :partial => 'spree/admin/orders/form', :locals => { :order => @order.reload }, :layout => false } end else respond_with(@line_item) do |format| format.html { render :partial => 'spree/admin/orders/form', :locals => { :order => @order.reload }, :layout => false } end end end |
#load_line_item ⇒ Object
59 60 61 |
# File 'app/controllers/spree/admin/line_items_controller.rb', line 59 def load_line_item @line_item = @order.line_items.find params[:id] end |
#load_order ⇒ Object
55 56 57 |
# File 'app/controllers/spree/admin/line_items_controller.rb', line 55 def load_order @order = Order.find_by_number! params[:order_id] end |
#new ⇒ Object
37 38 39 40 41 |
# File 'app/controllers/spree/admin/line_items_controller.rb', line 37 def new respond_with do |format| format.html { render :action => :new, :layout => false } end end |
#update ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/controllers/spree/admin/line_items_controller.rb', line 43 def update if @line_item.update_attributes(params[:line_item]) respond_with(@line_item) do |format| format.html { render :partial => 'spree/admin/orders/form', :locals => { :order => @order.reload }, :layout => false} end else respond_with(@line_item) do |format| format.html { render :partial => 'spree/admin/orders/form', :locals => { :order => @order.reload }, :layout => false} end end end |