Something not right here with Kate.
This commit is contained in:
parent
1eb8c2753f
commit
d882c1a521
@ -1,5 +1,6 @@
|
||||
class CredentialsController < ApplicationController
|
||||
before_action :set_credential, only: %i[ show edit update destroy ]
|
||||
before_action :set_domain, only: %i[ new ]
|
||||
|
||||
# GET /credentials or /credentials.json
|
||||
def index
|
||||
@ -63,6 +64,10 @@ class CredentialsController < ApplicationController
|
||||
@credential = Credential.find(params[:id])
|
||||
end
|
||||
|
||||
def set_domain
|
||||
@domain = Domain.find(params[:domain_id])
|
||||
end
|
||||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def credential_params
|
||||
params.require(:credential).permit(:email, :password)
|
||||
|
||||
@ -2,5 +2,6 @@ class Credential < ApplicationRecord
|
||||
belongs_to :domain
|
||||
validates :email, presence: true
|
||||
validates :email, uniqueness: true
|
||||
validates :domain_id, presence: true
|
||||
validates :email, format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i , message: "email must be valid"}
|
||||
end
|
||||
|
||||
@ -3,6 +3,7 @@ class Virtual < ApplicationRecord
|
||||
validate :domain_name_exists
|
||||
validates :email, presence: true
|
||||
validates :destination, presence: true
|
||||
validates :domain_id, presence: true
|
||||
validates :email, format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i , message: "email must be valid"}
|
||||
validates :destination, format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i , message: "destination must be valid"}
|
||||
validates :destination, uniqueness: {scope: :email, message: "a redirection pair must be unique"}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<%= form_with(model: credential) do |form| %>
|
||||
<%= form_with(model: [@domain, credential]) do |form| %>
|
||||
<% if credential.errors.any? %>
|
||||
<div style="color: red">
|
||||
<h2><%= pluralize(credential.errors.count, "error") %> prohibited this credential from being saved:</h2>
|
||||
|
||||
@ -5,5 +5,5 @@
|
||||
<br>
|
||||
|
||||
<div>
|
||||
<%= link_to "Back to credentials", credentials_path %>
|
||||
<%= link_to "Back to the domain", domain_path(@domain) %>
|
||||
</div>
|
||||
|
||||
@ -2,10 +2,7 @@
|
||||
<h1><%= @domain.domain %></h1>
|
||||
|
||||
<div>
|
||||
<%= link_to "Edit this domain", edit_domain_path(@domain) %> |
|
||||
<%= link_to "Back to domains", domains_path %>
|
||||
|
||||
<%= button_to "Destroy this domain", @domain, method: :delete %>
|
||||
<%= link_to "Edit this domain", edit_domain_path(@domain) %> | <%= link_to "Back to domains", domains_path %> | <%= button_to "Destroy this domain", @domain, method: :delete %>
|
||||
</div>
|
||||
|
||||
<h2>Credentials (<%= @domain.credentials.count %>)</h2>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user