# -*- encoding : utf-8 -*-
class Admin::ExternalLinksController < ApplicationController
	before_filter :auth_admin
	layout "admin"


	def cible
		@external_links = ExternalLink.all
		@external_link = ExternalLink.new
		render :layout => false
	
	
	end
	
	def new
		@external_link = ExternalLink.new

		respond_to do |format|
	
			format.js
		end
	end

	def edit
	
		@external_link = ExternalLink.find(params[:id])
	end


	def create
		@external_link = ExternalLink.new(params.require(:external_link).permit!)

		respond_to do |format|
			if @external_link.save
				flash[:notice] = "Le lien à été ajouté avec succès."
			
				format.js
			else
				format.html { render :action => "new" }
				format.js { render :action => "new" }
			end
		end
	end

	def update
	
		@external_link = ExternalLink.find(params[:id])
	
		respond_to do |format|
			if @external_link.update_attributes(params.require(:external_link).permit!)
			
			
				format.js
			else
			
				format.js { render :action => "edit" }
			end
		end
	end


	def destroy
		@external_link = ExternalLink.find(params[:id])
		@external_link.destroy

		respond_to do |format|
			format.js
		end 


	end
end
