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.

49 lines
983B

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