added virtuals
This commit is contained in:
70
app/controllers/virtuals_controller.rb
Normal file
70
app/controllers/virtuals_controller.rb
Normal file
@@ -0,0 +1,70 @@
|
||||
class VirtualsController < ApplicationController
|
||||
before_action :set_virtual, only: %i[ show edit update destroy ]
|
||||
|
||||
# GET /virtuals or /virtuals.json
|
||||
def index
|
||||
@virtuals = Virtual.all
|
||||
end
|
||||
|
||||
# GET /virtuals/1 or /virtuals/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /virtuals/new
|
||||
def new
|
||||
@virtual = Virtual.new
|
||||
end
|
||||
|
||||
# GET /virtuals/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /virtuals or /virtuals.json
|
||||
def create
|
||||
@virtual = Virtual.new(virtual_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @virtual.save
|
||||
format.html { redirect_to virtual_url(@virtual), notice: "Virtual was successfully created." }
|
||||
format.json { render :show, status: :created, location: @virtual }
|
||||
else
|
||||
format.html { render :new, status: :unprocessable_entity }
|
||||
format.json { render json: @virtual.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /virtuals/1 or /virtuals/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @virtual.update(virtual_params)
|
||||
format.html { redirect_to virtual_url(@virtual), notice: "Virtual was successfully updated." }
|
||||
format.json { render :show, status: :ok, location: @virtual }
|
||||
else
|
||||
format.html { render :edit, status: :unprocessable_entity }
|
||||
format.json { render json: @virtual.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /virtuals/1 or /virtuals/1.json
|
||||
def destroy
|
||||
@virtual.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to virtuals_url, notice: "Virtual was successfully destroyed." }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_virtual
|
||||
@virtual = Virtual.find(params[:id])
|
||||
end
|
||||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def virtual_params
|
||||
params.require(:virtual).permit(:email, :destination)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user