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

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

  def index
    @timeline_years = TimelineYear.all

   
  end

  def show
    @timeline_year = TimelineYear.find(params[:id])

  end

  def new
    
    
		@timeline_year = TimelineYear.new(:timeline_history_id => params[:timeline_history_id])
    

  end

 

  def edit
  
    
    @timeline_year = TimelineYear.find(params[:id])
  end

  def create
    @timeline_year = TimelineYear.new(params.require(:timeline_year).permit!)


    if @timeline_year.save
     redirect_to admin_timeline_history_url(@timeline_year.timeline_history.id), notice: 'Lannée a été crée.' 
      
    else
      render action: "new"
 
    end

  end


  def update
    @timeline_year = TimelineYear.find(params[:id])


    if @timeline_year.update_attributes(params.require(:timeline_year).permit!)
      redirect_to admin_timeline_history_url(@timeline_year.timeline_history.id), notice: 'Lannée a été crée.'  
     
    else
     render action: "edit" 
      
    end
      
  end


  def destroy
    @timeline_year = TimelineYear.find(params[:id])
    @timeline_year.destroy
    
    

  end
end
