Class: Workarea::Admin::FulfillmentTokensController
Instance Method Summary
collapse
#current_user, #find_sort, #wrap_in_view_model, wrap_in_view_model
Methods included from Publishing
#allow_publishing!, #allow_publishing?, #set_publishing_options
Methods included from Visiting
#most_visited
Instance Method Details
#create ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
|
# File 'app/controllers/workarea/admin/fulfillment_tokens_controller.rb', line 18
def create
@token = Fulfillment::Token.new(sku: @sku.id)
if @token.save
flash[:success] = t('workarea.admin.fulfillment_tokens.flash_messages.created')
else
flash[:error] = t('workarea.admin.fulfillment_tokens.flash_messages.error')
end
redirect_to fulfillment_sku_tokens_path(@sku, new_token: @token.id)
end
|
#index ⇒ Object
9
10
11
12
13
14
15
16
|
# File 'app/controllers/workarea/admin/fulfillment_tokens_controller.rb', line 9
def index
@tokens =
Fulfillment::Token
.for_sku(@sku.id)
.page(params[:page])
.per(Workarea.config.per_page)
.order_by(find_sort(Fulfillment::Token))
end
|
#update ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'app/controllers/workarea/admin/fulfillment_tokens_controller.rb', line 30
def update
result = @token.update(params[:token])
if result && @token.enabled?
flash[:success] = t('workarea.admin.fulfillment_tokens.flash_messages.enabled')
elsif result
flash[:success] = t('workarea.admin.fulfillment_tokens.flash_messages.disabled')
else
flash[:error] = t('workarea.admin.fulfillment_tokens.flash_messages.update_failed')
end
redirect_back_or fulfillment_sku_tokens_path(@sku)
end
|