Class: Workarea::Api::Admin::TaxCategoriesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/workarea/api/admin/tax_categories_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_user, #sort_direction, #sort_field

Instance Method Details

#bulkObject



225
226
227
228
229
230
231
232
# File 'app/controllers/workarea/api/admin/tax_categories_controller.rb', line 225

def bulk
  @bulk = Api::Admin::BulkUpsert.create!(
    klass: Tax::Category,
    data: params[:tax_categories].map(&:to_h)
  )

  head :no_content
end

#createObject



81
82
83
84
85
86
87
88
# File 'app/controllers/workarea/api/admin/tax_categories_controller.rb', line 81

def create
  @tax_category = Tax::Category.create!(params[:tax_category])
  respond_with(
    { tax_category: @tax_category },
    { status: :created,
    location: tax_category_path(@tax_category) }
  )
end

#destroyObject



191
192
193
194
# File 'app/controllers/workarea/api/admin/tax_categories_controller.rb', line 191

def destroy
  @tax_category.destroy
  head :no_content
end

#indexObject



72
73
74
75
76
77
78
79
# File 'app/controllers/workarea/api/admin/tax_categories_controller.rb', line 72

def index
  @tax_categories = Tax::Category
                        .all
                        .order_by(sort_field => sort_direction)
                        .page(params[:page])

  respond_with tax_categories: @tax_categories
end

#showObject



182
183
184
# File 'app/controllers/workarea/api/admin/tax_categories_controller.rb', line 182

def show
  respond_with tax_category: @tax_category
end

#updateObject



186
187
188
189
# File 'app/controllers/workarea/api/admin/tax_categories_controller.rb', line 186

def update
  @tax_category.update_attributes!(params[:tax_category])
  respond_with tax_category: @tax_category
end