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

class Admin::PartnersController < ApplicationController
  layout "admin"
  before_filter :auth_admin
  
  def index
    @partners = Partner.all
  end

  def new
    @partner = Partner.new
  end

  def edit
    @partner = Partner.find(params[:id])
  end

  def create
    @partner = Partner.new(params.require(:partner).permit!)

 
    if @partner.save
      redirect_to admin_partners_url, notice: 'Url courte crée.' 
      
    else
      render action: "new" 
 
    end

  end

  def update
    @partner = Partner.find(params[:id])

   
    if @partner.update_attributes(params.require(:partner).permit!)
      redirect_to admin_partners_url, notice: 'Url courte modifiée.' 
     
    else
      render action: "edit" 
      
    end
    
  end

 
  def destroy
    @partner = Partner.find(params[:id])
    @partner.destroy

     redirect_to admin_partners_url, :notice => "Url courte supprimée."
  end
end
