app/controllers/comable/orders_controller.rb in comable_frontend-0.2.1 vs app/controllers/comable/orders_controller.rb in comable_frontend-0.2.2

- old
+ new

@@ -3,19 +3,14 @@ prepend Comable::ShipmentAction prepend Comable::PaymentAction before_filter :load_order before_filter :verify - before_filter :redirect_for_logged_in_customer, only: [:new, :orderer] after_filter :save_order, except: :create - rescue_from ActiveRecord::RecordInvalid, with: :record_invalid rescue_from Comable::InvalidOrder, with: :order_invalid - def new - end - def orderer case request.method_symbol when :post redirect_to comable.delivery_order_path end @@ -26,26 +21,27 @@ when :post redirect_to next_order_path end end - def confirm - end - def create order = current_customer.order if order.complete? - Comable::OrderMailer.complete(order).deliver if current_store.email_activate? flash[:notice] = I18n.t('comable.orders.success') + send_order_complete_mail else flash[:alert] = I18n.t('comable.orders.failure') redirect_to comable.confirm_order_path end end private + def send_order_complete_mail + Comable::OrderMailer.complete(@order).deliver if current_store.email_activate? + end + def next_order_path(target_action_name = nil) case (target_action_name || action_name).to_sym when :delivery shipment_required? ? comable.shipment_order_path : next_order_path(:shipment) when :shipment @@ -95,20 +91,11 @@ :first_name ] ) end - def redirect_for_logged_in_customer - return redirect_to delivery_order_path if current_customer.logged_in? - end - - def record_invalid + def order_invalid flash[:alert] = I18n.t('comable.orders.failure') - redirect_to comable.cart_path - end - - def order_invalid(exception) - flash[:alert] = exception.message redirect_to comable.cart_path end end end