# -*- encoding : utf-8 -*-

class Admin::TimelineHistoriesController < ApplicationController
  layout "admin"
  before_action :auth_admin

  def index
    @timeline_histories = TimelineHistory.all

   
  end

  def show
    @timeline_history = TimelineHistory.find(params[:id])

  end

  def new
    
    
		@timeline_history = TimelineHistory.new
    

  end

 

  def edit
  
    
    @timeline_history = TimelineHistory.find(params[:id])
  end

  def create
    @timeline_history = TimelineHistory.new(params.require(:timeline_history).permit!)


    if @timeline_history.save
     redirect_to admin_timeline_histories_url, notice: 'La pétition a été crée.' 
      
    else
      render action: "new"
 
    end

  end


  def update
    @timeline_history = TimelineHistory.find(params[:id])


    if @timeline_history.update_attributes(params.require(:timeline_history).permit!)
      redirect_to admin_timeline_histories_url, notice: 'Les infos sur la pétition ont été mise à jour.' 
     
    else
     render action: "edit" 
      
    end
      
  end


  def destroy
    @timeline_history = TimelineHistory.find(params[:id])
    @timeline_history.destroy
    
    redirect_to admin_timeline_histories_url

  end
end
