Class: Kms::TemplatesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Kms::TemplatesController
- Defined in:
- app/controllers/kms/templates_controller.rb
Instance Method Summary collapse
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'app/controllers/kms/templates_controller.rb', line 8 def create @template = Template.new(template_params) @template.content = TemplateProcessor.new(@template).process if @template.save head :no_content else render json: { errors: @template.errors. }.to_json, status: :unprocessable_entity end end |
#destroy ⇒ Object
32 33 34 35 36 |
# File 'app/controllers/kms/templates_controller.rb', line 32 def destroy @template = Template.find(params[:id]) @template.destroy head :no_content end |
#index ⇒ Object
4 5 6 |
# File 'app/controllers/kms/templates_controller.rb', line 4 def index render json: Template.all end |
#show ⇒ Object
27 28 29 30 |
# File 'app/controllers/kms/templates_controller.rb', line 27 def show @template = Template.find(params[:id]) render json: @template end |
#update ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'app/controllers/kms/templates_controller.rb', line 18 def update @template = Template.find(params[:id]) if @template.update(template_params) head :no_content else render json: { errors: @template.errors. }.to_json, status: :unprocessable_entity end end |