The code powering m.abunchtell.com https://m.abunchtell.com
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.
 
 
 
 

59 lines
1.1 KiB

  1. # frozen_string_literal: true
  2. module Admin
  3. class RelaysController < BaseController
  4. before_action :set_relay, except: [:index, :new, :create]
  5. def index
  6. authorize :relay, :update?
  7. @relays = Relay.all
  8. end
  9. def new
  10. authorize :relay, :update?
  11. @relay = Relay.new(inbox_url: Relay::PRESET_RELAY)
  12. end
  13. def create
  14. authorize :relay, :update?
  15. @relay = Relay.new(resource_params)
  16. if @relay.save
  17. @relay.enable!
  18. redirect_to admin_relays_path
  19. else
  20. render action: :new
  21. end
  22. end
  23. def destroy
  24. authorize :relay, :update?
  25. @relay.destroy
  26. redirect_to admin_relays_path
  27. end
  28. def enable
  29. authorize :relay, :update?
  30. @relay.enable!
  31. redirect_to admin_relays_path
  32. end
  33. def disable
  34. authorize :relay, :update?
  35. @relay.disable!
  36. redirect_to admin_relays_path
  37. end
  38. private
  39. def set_relay
  40. @relay = Relay.find(params[:id])
  41. end
  42. def resource_params
  43. params.require(:relay).permit(:inbox_url)
  44. end
  45. end
  46. end