Class: CompletionKit::Api::V1::DatasetsController
- Inherits:
-
BaseController
- Object
- ActionController::API
- BaseController
- CompletionKit::Api::V1::DatasetsController
- Defined in:
- app/controllers/completion_kit/api/v1/datasets_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'app/controllers/completion_kit/api/v1/datasets_controller.rb', line 17 def create dataset = Dataset.new(dataset_params) if dataset.save render json: dataset, status: :created else render json: {errors: dataset.errors}, status: :unprocessable_entity end end |
#destroy ⇒ Object
34 35 36 37 |
# File 'app/controllers/completion_kit/api/v1/datasets_controller.rb', line 34 def destroy @dataset.destroy! head :no_content end |
#index ⇒ Object
7 8 9 10 11 |
# File 'app/controllers/completion_kit/api/v1/datasets_controller.rb', line 7 def index scope = Dataset.includes(:tags) scope = (scope) render json: paginate(scope.order(created_at: :desc)) end |
#show ⇒ Object
13 14 15 |
# File 'app/controllers/completion_kit/api/v1/datasets_controller.rb', line 13 def show render json: @dataset end |
#update ⇒ Object
26 27 28 29 30 31 32 |
# File 'app/controllers/completion_kit/api/v1/datasets_controller.rb', line 26 def update if @dataset.update(dataset_params) render json: @dataset else render json: {errors: @dataset.errors}, status: :unprocessable_entity end end |