Added doamins
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
class ApplicationController < ActionController::Base
|
||||
before_action :authenticate_user!
|
||||
end
|
||||
|
||||
70
app/controllers/domains_controller.rb
Normal file
70
app/controllers/domains_controller.rb
Normal file
@@ -0,0 +1,70 @@
|
||||
class DomainsController < ApplicationController
|
||||
before_action :set_domain, only: %i[ show edit update destroy ]
|
||||
|
||||
# GET /domains or /domains.json
|
||||
def index
|
||||
@domains = Domain.all
|
||||
end
|
||||
|
||||
# GET /domains/1 or /domains/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /domains/new
|
||||
def new
|
||||
@domain = Domain.new
|
||||
end
|
||||
|
||||
# GET /domains/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /domains or /domains.json
|
||||
def create
|
||||
@domain = Domain.new(domain_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @domain.save
|
||||
format.html { redirect_to domain_url(@domain), notice: "Domain was successfully created." }
|
||||
format.json { render :show, status: :created, location: @domain }
|
||||
else
|
||||
format.html { render :new, status: :unprocessable_entity }
|
||||
format.json { render json: @domain.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /domains/1 or /domains/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @domain.update(domain_params)
|
||||
format.html { redirect_to domain_url(@domain), notice: "Domain was successfully updated." }
|
||||
format.json { render :show, status: :ok, location: @domain }
|
||||
else
|
||||
format.html { render :edit, status: :unprocessable_entity }
|
||||
format.json { render json: @domain.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /domains/1 or /domains/1.json
|
||||
def destroy
|
||||
@domain.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to domains_url, notice: "Domain was successfully destroyed." }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_domain
|
||||
@domain = Domain.find(params[:id])
|
||||
end
|
||||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def domain_params
|
||||
params.require(:domain).permit(:domain)
|
||||
end
|
||||
end
|
||||
2
app/helpers/domains_helper.rb
Normal file
2
app/helpers/domains_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module DomainsHelper
|
||||
end
|
||||
2
app/models/domain.rb
Normal file
2
app/models/domain.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
class Domain < ApplicationRecord
|
||||
end
|
||||
7
app/views/domains/_domain.html.erb
Normal file
7
app/views/domains/_domain.html.erb
Normal file
@@ -0,0 +1,7 @@
|
||||
<div id="<%= dom_id domain %>">
|
||||
<p>
|
||||
<strong>Domain:</strong>
|
||||
<%= domain.domain %>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
2
app/views/domains/_domain.json.jbuilder
Normal file
2
app/views/domains/_domain.json.jbuilder
Normal file
@@ -0,0 +1,2 @@
|
||||
json.extract! domain, :id, :domain, :created_at, :updated_at
|
||||
json.url domain_url(domain, format: :json)
|
||||
22
app/views/domains/_form.html.erb
Normal file
22
app/views/domains/_form.html.erb
Normal file
@@ -0,0 +1,22 @@
|
||||
<%= form_with(model: domain) do |form| %>
|
||||
<% if domain.errors.any? %>
|
||||
<div style="color: red">
|
||||
<h2><%= pluralize(domain.errors.count, "error") %> prohibited this domain from being saved:</h2>
|
||||
|
||||
<ul>
|
||||
<% domain.errors.each do |error| %>
|
||||
<li><%= error.full_message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div>
|
||||
<%= form.label :domain, style: "display: block" %>
|
||||
<%= form.text_field :domain %>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= form.submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
10
app/views/domains/edit.html.erb
Normal file
10
app/views/domains/edit.html.erb
Normal file
@@ -0,0 +1,10 @@
|
||||
<h1>Editing domain</h1>
|
||||
|
||||
<%= render "form", domain: @domain %>
|
||||
|
||||
<br>
|
||||
|
||||
<div>
|
||||
<%= link_to "Show this domain", @domain %> |
|
||||
<%= link_to "Back to domains", domains_path %>
|
||||
</div>
|
||||
14
app/views/domains/index.html.erb
Normal file
14
app/views/domains/index.html.erb
Normal file
@@ -0,0 +1,14 @@
|
||||
<p style="color: green"><%= notice %></p>
|
||||
|
||||
<h1>Domains</h1>
|
||||
|
||||
<div id="domains">
|
||||
<% @domains.each do |domain| %>
|
||||
<%= render domain %>
|
||||
<p>
|
||||
<%= link_to "Show this domain", domain %>
|
||||
</p>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<%= link_to "New domain", new_domain_path %>
|
||||
1
app/views/domains/index.json.jbuilder
Normal file
1
app/views/domains/index.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.array! @domains, partial: "domains/domain", as: :domain
|
||||
9
app/views/domains/new.html.erb
Normal file
9
app/views/domains/new.html.erb
Normal file
@@ -0,0 +1,9 @@
|
||||
<h1>New domain</h1>
|
||||
|
||||
<%= render "form", domain: @domain %>
|
||||
|
||||
<br>
|
||||
|
||||
<div>
|
||||
<%= link_to "Back to domains", domains_path %>
|
||||
</div>
|
||||
10
app/views/domains/show.html.erb
Normal file
10
app/views/domains/show.html.erb
Normal file
@@ -0,0 +1,10 @@
|
||||
<p style="color: green"><%= notice %></p>
|
||||
|
||||
<%= render @domain %>
|
||||
|
||||
<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 %>
|
||||
</div>
|
||||
1
app/views/domains/show.json.jbuilder
Normal file
1
app/views/domains/show.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.partial! "domains/domain", domain: @domain
|
||||
Reference in New Issue
Block a user