Looking for changes on website content https://projet-alice-demo.herokuapp.com/diffs/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
975B

  1. class TemplatesController < ApplicationController
  2. before_action :set_template, only: %i[edit update destroy]
  3. before_action :must_be_authenticated, only: %i[new create edit update destroy]
  4. def new
  5. @template = ::Template.new
  6. end
  7. def create
  8. @template = ::Template.new(template_params)
  9. if @template.save
  10. redirect_to config_index_path, notice: 'Template has been successfully created.'
  11. else
  12. render :new
  13. end
  14. end
  15. def edit
  16. end
  17. def update
  18. if @template.update(template_params)
  19. redirect_to config_index_path, notice: 'Template has been successfully updated.'
  20. else
  21. render :edit
  22. end
  23. end
  24. def destroy
  25. @template.destroy
  26. redirect_to config_index_path, notice: 'Template has been successfully removed.'
  27. end
  28. private
  29. def set_template
  30. @template = ::Template.find params[:id]
  31. end
  32. def template_params
  33. params.require(:template).permit(
  34. :id, :name,
  35. targets_attributes: %i[id name css from to group_id _destroy],
  36. )
  37. end
  38. end