scaffold models
This commit is contained in:
74
app/controllers/settings/zones_controller.rb
Normal file
74
app/controllers/settings/zones_controller.rb
Normal file
@@ -0,0 +1,74 @@
|
||||
class Settings::ZonesController < ApplicationController
|
||||
before_action :set_settings_zone, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
# GET /settings/zones
|
||||
# GET /settings/zones.json
|
||||
def index
|
||||
@settings_zones = Zone.all
|
||||
end
|
||||
|
||||
# GET /settings/zones/1
|
||||
# GET /settings/zones/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /settings/zones/new
|
||||
def new
|
||||
@settings_zone = Zone.new
|
||||
end
|
||||
|
||||
# GET /settings/zones/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /settings/zones
|
||||
# POST /settings/zones.json
|
||||
def create
|
||||
@settings_zone = Zone.new(settings_zone_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @settings_zone.save
|
||||
format.html { redirect_to @settings_zone, notice: 'Zone was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @settings_zone }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @settings_zone.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /settings/zones/1
|
||||
# PATCH/PUT /settings/zones/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @settings_zone.update(settings_zone_params)
|
||||
format.html { redirect_to @settings_zone, notice: 'Zone was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @settings_zone }
|
||||
else
|
||||
format.html { render :edit }
|
||||
format.json { render json: @settings_zone.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /settings/zones/1
|
||||
# DELETE /settings/zones/1.json
|
||||
def destroy
|
||||
@settings_zone.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to settings_zones_url, notice: 'Zone was successfully destroyed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_settings_zone
|
||||
@settings_zone = Zone.find(params[:id])
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def settings_zone_params
|
||||
params.require(:settings_zone).permit(:name, :is_active, :created_by)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user