This repository has been archived on 2021-11-24. You can view files and clone it, but cannot push or open issues or pull requests.
phone_app/app/controllers/admin/popups_controller.rb
2021-08-23 10:26:02 +02:00

98 lines
1.1 KiB
Ruby

# -*- encoding : utf-8 -*-
class Admin::PopupsController < ApplicationController
before_action :auth_admin
layout "admin"
def index
@popups = Popup.order("created_at DESC").all
end
def new
@popup = Popup.new()
end
def edit
@popup = Popup.find(params[:id])
end
def show
@lang = LangSite.find_by_slug(params[:lang])
@popup = Popup.find(params[:id])
end
def create
@popup = Popup.new(params.require(:popup).permit!)
if @popup.save
flash[:notice] = "La popup à été ajouté avec succès."
redirect_to :action => :index
else
render :action => "new"
end
end
def update
@popup = Popup.find(params[:id])
if @popup.update_attributes(params.require(:popup).permit!)
flash[:notice] = "La popup à été modifié avec succès."
redirect_to :action => :index
else
render :action => "edit"
end
end
def destroy
@popup = Popup.find(params[:id])
@popup.destroy
redirect_to :action => :index
end
end