Class: Refinery::Orders::OrdersController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Refinery::Orders::OrdersController
- Defined in:
- app/controllers/refinery/orders/orders_controller.rb
Instance Method Summary collapse
- #cancel_order ⇒ Object
-
#edit ⇒ Object
edit must present the view appropriate to order state.
- #index ⇒ Object
-
#purchase ⇒ Object
displays the successful purchase page.
- #re_edit ⇒ Object
- #show ⇒ Object
-
#update ⇒ Object
update must proceed within confines of order state machine but must validate params as well.
Instance Method Details
#cancel_order ⇒ Object
65 66 67 68 69 |
# File 'app/controllers/refinery/orders/orders_controller.rb', line 65 def cancel_order @order.cancel_process! flash[:notice] = "you may continue your order any time" redirect_to refinery.stores_stores_path end |
#edit ⇒ Object
edit must present the view appropriate to order state
40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/refinery/orders/orders_controller.rb', line 40 def edit if (@action = @order.get_render_template).nil? flash[:notice] = "invalid order processing attempted" redirect_to refinery.stores_stores_path else prep_edit_view render :action => @action end # if..then..else no action end |
#index ⇒ Object
17 18 19 20 21 |
# File 'app/controllers/refinery/orders/orders_controller.rb', line 17 def index # you can use meta fields from your model instead (e.g. browser_title) # by swapping @page for @order in the line below: present(@order) end |
#purchase ⇒ Object
displays the successful purchase page
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/controllers/refinery/orders/orders_controller.rb', line 51 def purchase @order.confirm_purchase! @order.process_purchase( @payment_gateway ) if @order.errors.empty? @action = :purchase_complete @purchase_status = "thank you for your purchase" else @action = :purchase_pending @purchase_status = "Purchase unsuccessful; please correct errors and try again." end end |
#re_edit ⇒ Object
71 72 73 74 |
# File 'app/controllers/refinery/orders/orders_controller.rb', line 71 def re_edit @order.restart_checkout! edit end |
#show ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'app/controllers/refinery/orders/orders_controller.rb', line 23 def show if (@action = @order.get_render_template).nil? present(@order) else prep_edit_view render :action => @action end # if..then..else no action end |
#update ⇒ Object
update must proceed within confines of order state machine but must validate params as well
34 35 36 37 |
# File 'app/controllers/refinery/orders/orders_controller.rb', line 34 def update @billing_address, @shipping_address = @order.handle_update( params ) edit end |