Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Shared::EventsController < ApplicationController
- layout 'admin/panel'
- before_action :set_event , only: [:edit , :update, :show ,:destroy]
- def index
- @events = Event.all
- end
- def new
- @event = Event.new
- end
- def create
- @event = Event.new(params_event)
- if @event.save
- redirect_to shared_events_path, notice: "Pedido Salvo com sucesso!!"
- else
- render :new
- end
- end
- def edit
- end
- def update
- if @event.update(params_event)
- redirect_to shared_events_path, notice: "Pedido Editado com sucesso!!"
- else
- render :edit
- end
- end
- def set_event
- @event = Event.find(params[:id])
- end
- def show
- end
- def destroy
- if @event.destroy
- redirect_to shared_events_path, notice: "Pedido excluido com sucesso!!"
- else
- render :index
- end
- end
- private
- def params_event
- params.require(:event).permit(
- :title,
- :data_inicio,
- :data_fim,
- :description
- )
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement