Class: Workarea::Api::Admin::CategoriesController
Instance Method Summary
collapse
#current_user, #sort_direction, #sort_field
Instance Method Details
#bulk ⇒ Object
289
290
291
292
293
294
295
296
|
# File 'app/controllers/workarea/api/admin/categories_controller.rb', line 289
def bulk
@bulk = Api::Admin::BulkUpsert.create!(
klass: Catalog::Category,
data: params[:categories].map(&:to_h)
)
head :no_content
end
|
#create ⇒ Object
112
113
114
115
116
117
118
119
|
# File 'app/controllers/workarea/api/admin/categories_controller.rb', line 112
def create
@category = Catalog::Category.create!(params[:category])
respond_with(
{ category: @category },
{ status: :created,
location: category_path(@category.id) }
)
end
|
#destroy ⇒ Object
298
299
300
301
|
# File 'app/controllers/workarea/api/admin/categories_controller.rb', line 298
def destroy
@category.destroy
head :no_content
end
|
#index ⇒ Object
101
102
103
104
105
106
107
108
109
110
|
# File 'app/controllers/workarea/api/admin/categories_controller.rb', line 101
def index
@categories = Catalog::Category
.all
.by_updated_at(starts_at: params[:updated_at_starts_at], ends_at: params[:updated_at_ends_at])
.by_created_at(starts_at: params[:created_at_starts_at], ends_at: params[:created_at_ends_at])
.order_by(sort_field => sort_direction)
.page(params[:page])
respond_with categories: @categories
end
|
#show ⇒ Object
251
252
253
|
# File 'app/controllers/workarea/api/admin/categories_controller.rb', line 251
def show
respond_with category: @category
end
|
#update ⇒ Object
255
256
257
258
|
# File 'app/controllers/workarea/api/admin/categories_controller.rb', line 255
def update
@category.update_attributes!(params[:category])
respond_with category: @category
end
|