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.

54 lines
1020B

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