diff --git a/app/controllers/webhooks_controller.rb b/app/controllers/webhooks_controller.rb index ddd0f09da..fceb37c5c 100644 --- a/app/controllers/webhooks_controller.rb +++ b/app/controllers/webhooks_controller.rb @@ -17,24 +17,16 @@ class WebhooksController < ApplicationController end def create - @webhook = @collection.webhooks.new(webhook_params) - - if @webhook.save - redirect_to @webhook - else - render :new, status: :unprocessable_entity - end + @webhook = @collection.webhooks.create!(webhook_params) + redirect_to @webhook end def edit end def update - if @webhook.update(webhook_params.except(:url)) - redirect_to @webhook - else - render :edit, status: :unprocessable_entity - end + @webhook.update!(webhook_params.except(:url)) + redirect_to @webhook end def destroy diff --git a/app/views/webhooks/new.html.erb b/app/views/webhooks/new.html.erb index 98c5642f7..780088117 100644 --- a/app/views/webhooks/new.html.erb +++ b/app/views/webhooks/new.html.erb @@ -11,7 +11,13 @@ <%= form.text_field :name, required: true, autofocus: true, class: "input", placeholder: "Name your Webhook…", data: { action: "keydown.esc@document->form#cancel" } %> - <%= form.text_field :url, required: true, class: "input", placeholder: "https://example.com", data: { action: "keydown.esc@document->form#cancel" } %> + <%= form.url_field :url, + required: true, + pattern: "https?://.*", + title: "Must be an http:// or https:// URL", + class: "input", + placeholder: "https://example.com", + data: { action: "keydown.esc@document->form#cancel" } %>