Class: Workarea::Admin::TaxRatesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/workarea/admin/tax_rates_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#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

#createObject



19
20
21
22
23
24
25
26
27
# File 'app/controllers/workarea/admin/tax_rates_controller.rb', line 19

def create
  if @category.rates.new(rate_params).save
    flash[:success] = t('workarea.admin.tax_rates.flash_messages.saved')
    redirect_to tax_category_rates_path
  else
    flash[:error] = t('workarea.admin.tax_rates.flash_messages.changes_error')
    render :new
  end
end

#destroyObject



42
43
44
45
46
47
# File 'app/controllers/workarea/admin/tax_rates_controller.rb', line 42

def destroy
  @rate.destroy

  flash[:success] = t('workarea.admin.tax_rates.flash_messages.removed')
  redirect_to tax_category_rates_path
end

#editObject



29
30
# File 'app/controllers/workarea/admin/tax_rates_controller.rb', line 29

def edit
end

#indexObject



9
10
11
12
13
# File 'app/controllers/workarea/admin/tax_rates_controller.rb', line 9

def index
  @rates = @category.rates.search(params[:q])
    .page(params[:page])
    .order_by(find_sort(Tax::Rate))
end

#newObject



15
16
17
# File 'app/controllers/workarea/admin/tax_rates_controller.rb', line 15

def new
  @rate = @category.rates.new
end

#updateObject



32
33
34
35
36
37
38
39
40
# File 'app/controllers/workarea/admin/tax_rates_controller.rb', line 32

def update
  if @rate.update_attributes(rate_params)
    flash[:success] = t('workarea.admin.tax_rates.flash_messages.saved')
    redirect_to tax_category_rates_path
  else
    flash[:error] = t('workarea.admin.tax_rates.flash_messages.changes_error')
    render :edit
  end
end