52 lines
896 B
Ruby
52 lines
896 B
Ruby
|
|
class SitemapsController < ApplicationController
|
||
|
|
before_action :authenticate_user!, only: %i[new edit update create destroy]
|
||
|
|
allow_unauthenticated_access only: %i[index show]
|
||
|
|
|
||
|
|
def index
|
||
|
|
@sitemap = Sitemap.all
|
||
|
|
end
|
||
|
|
|
||
|
|
def new
|
||
|
|
@sitemap = Sitemap.new
|
||
|
|
end
|
||
|
|
|
||
|
|
def create
|
||
|
|
@sitemap = Sitemap.new(sitemap_params)
|
||
|
|
if @sitemap.save
|
||
|
|
redirect_to @sitemap
|
||
|
|
else
|
||
|
|
render :new
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
def show
|
||
|
|
@sitemap = Sitemap.find(params[:id])
|
||
|
|
end
|
||
|
|
|
||
|
|
def edit
|
||
|
|
@sitemap = Sitemap.find(params[:id])
|
||
|
|
end
|
||
|
|
|
||
|
|
def update
|
||
|
|
@sitemap = Sitemap.find(params[:id])
|
||
|
|
if @sitemap.update(sitemap_params)
|
||
|
|
redirect_to @sitemap
|
||
|
|
else
|
||
|
|
render :edit
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
def destroy
|
||
|
|
@sitemap = Sitemap.find(params[:id])
|
||
|
|
@sitemap.destroy
|
||
|
|
redirect_to sitemaps_path
|
||
|
|
end
|
||
|
|
|
||
|
|
private
|
||
|
|
|
||
|
|
def sitemap_params
|
||
|
|
params.require(:sitemap).permit(:text)
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|