crossey_app/app/controllers/admin/testimonies_controller.rb
2013-09-30 17:42:55 +02:00

85 lines
1.1 KiB
Ruby

# -*- encoding : utf-8 -*-
class Admin::TestimoniesController < ApplicationController
layout "admin"
before_filter :auth_admin
def index
@testimonies = Testimony.order("created_at DESC").all
end
def new
@testimony = Testimony.new
end
def edit
@testimony = Testimony.find(params[:id])
end
def show
@testimony = Testimony.find(params[:id])
end
def create
@testimony = Testimony.new(testimony_params)
if @testimony.save
else
render :action => "new"
end
end
def update
@testimony = Testimony.find(params[:id])
if @testimony.update_attributes(testimony_params)
else
end
end
def destroy
@testimony = Testimony.find(params[:id])
@testimony.destroy
flash[:notice] = "Le témoignage de "+@testimony.author.to_s+" a bien été supprimé."
end
private
def testimony_params
params.require(:testimony).permit(:quote,:author, :image_file_id)
end
end