Simplify setup and pull query-prevention into model

This commit is contained in:
David Heinemeier Hansson
2025-11-03 15:00:15 +01:00
parent 2bf95f5b9a
commit 995dcfe8e6
2 changed files with 6 additions and 10 deletions
@@ -1,14 +1,10 @@
class Webhooks::ActivationsController < ApplicationController
before_action :ensure_admin
before_action :set_webhook
def create
@webhook.activate unless @webhook.active?
redirect_to @webhook
end
webhook = Webhook.find(params[:webhook_id])
webhook.activate
private
def set_webhook
@webhook = Webhook.find(params[:webhook_id])
end
redirect_to webhook
end
end
+2 -2
View File
@@ -40,11 +40,11 @@ class Webhook < ApplicationRecord
validate :validate_url
def activate
update_columns active: true
update! active: true unless active?
end
def deactivate
update_columns active: false
update! active: false
end
def renderer