Class: Comable::Admin::DraftOrdersController
Instance Method Summary
collapse
#current_ability, #respond_to_export_with
Instance Method Details
#create ⇒ Object
23
24
25
26
27
28
29
30
31
32
|
# File 'app/controllers/comable/admin/draft_orders_controller.rb', line 23
def create
if save_order_as_draft
@order.update!(draft: false) if @order.completed?
redirect_to admin_order_path, notice: Comable.t('successful')
else
build_associations
flash.now[:alert] = Comable.t('failure')
render :new
end
end
|
#edit ⇒ Object
34
35
|
# File 'app/controllers/comable/admin/draft_orders_controller.rb', line 34
def edit
end
|
#index ⇒ Object
10
11
12
13
|
# File 'app/controllers/comable/admin/draft_orders_controller.rb', line 10
def index
@q = Comable::Order.draft.ransack(params[:q])
@orders = @q.result.page(params[:page]).per(15).recent.accessible_by(current_ability)
end
|
#new ⇒ Object
19
20
21
|
# File 'app/controllers/comable/admin/draft_orders_controller.rb', line 19
def new
build_associations
end
|
#show ⇒ Object
15
16
17
|
# File 'app/controllers/comable/admin/draft_orders_controller.rb', line 15
def show
render :edit
end
|
#update ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
|
# File 'app/controllers/comable/admin/draft_orders_controller.rb', line 37
def update
@order.attributes = order_params
if save_order_as_draft
@order.update!(draft: false) if @order.completed?
redirect_to admin_order_path, notice: Comable.t('successful')
else
flash.now[:alert] = Comable.t('failure')
render :edit
end
end
|