Class: Kms::SnippetsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Kms::SnippetsController
- Defined in:
- app/controllers/kms/snippets_controller.rb
Instance Method Summary collapse
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'app/controllers/kms/snippets_controller.rb', line 10 def create @snippet = Snippet.new(snippet_params) if @snippet.save head :no_content else render json: { errors: @snippet.errors. }.to_json, status: :unprocessable_entity end end |
#destroy ⇒ Object
33 34 35 36 37 |
# File 'app/controllers/kms/snippets_controller.rb', line 33 def destroy @snippet = Snippet.find(params[:id]) @snippet.destroy head :no_content end |
#index ⇒ Object
6 7 8 |
# File 'app/controllers/kms/snippets_controller.rb', line 6 def index render json: Snippet.all, root: false end |
#show ⇒ Object
28 29 30 31 |
# File 'app/controllers/kms/snippets_controller.rb', line 28 def show @snippet = Snippet.find(params[:id]) render json: @snippet, root: false end |
#update ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'app/controllers/kms/snippets_controller.rb', line 19 def update @snippet = Snippet.find(params[:id]) if @snippet.update(snippet_params) head :no_content else render json: { errors: @snippet.errors. }.to_json, status: :unprocessable_entity end end |