pic_vert_app/app/controllers/admin/petitions_controller.rb
2013-06-28 20:35:32 +02:00

65 lines
1005 B
Ruby

# -*- encoding : utf-8 -*-
class Admin::PetitionsController < ApplicationController
layout "admin"
before_filter :authenticate_admin!
def index
@petitions = Petition.all
end
def show
@petition = Petition.find(params[:id])
end
def new
@petition = Petition.new
end
def edit
@petition = Petition.find(params[:id])
end
def create
@petition = Petition.new(params[:petition])
if @petition.save
redirect_to admin_petitions_url, notice: 'La pétition a été crée.'
else
render action: "new"
end
end
def update
@petition = Petition.find(params[:id])
if @petition.update_attributes(params[:petition])
redirect_to admin_petitions_url, notice: 'Les infos sur la pétition ont été mise à jour.'
else
render action: "edit"
end
end
def destroy
@petition = Petition.find(params[:id])
@petition.destroy
redirect_to admin_petitions_url
end
end