1
0

services_controller.rb 874 B

123456789101112131415161718192021222324252627282930313233343536
  1. class ServicesController < ApplicationController
  2. include SortableTable
  3. before_action :upgrade_warning, only: :index
  4. def index
  5. set_table_sort sorts: %w[provider name global], default: { provider: :asc }
  6. @services = current_user.services.reorder(table_sort).page(params[:page])
  7. respond_to do |format|
  8. format.html
  9. format.json { render json: @services }
  10. end
  11. end
  12. def destroy
  13. @services = current_user.services.find(params[:id])
  14. @services.destroy
  15. respond_to do |format|
  16. format.html { redirect_to services_path }
  17. format.json { head :no_content }
  18. end
  19. end
  20. def toggle_availability
  21. @service = current_user.services.find(params[:id])
  22. @service.toggle_availability!
  23. respond_to do |format|
  24. format.html { redirect_to services_path }
  25. format.json { render json: @service }
  26. end
  27. end
  28. end