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

class Admin::InterestsController < ApplicationController
	before_filter :authenticate_admin!

	layout "admin"
	
	navigation :interests

	before_filter :find_interests

	def index 

	end

	def cible
		@interests = Interest.all
		
		render :layout => false
		
	end
	
	def new	
		@interest = Interest.new

	end

	def edit
		@interest = Interest.find(params[:id])
		
	end


	def create
		@interest = Interest.new(params[:interest])

	
		if @interest.save
			flash[:notice] = "Le centre d'intêret a bien été ajouté."
			self.find_interests

		else
			render :action => "new" 
			
		end
	
	end


	def update
		@interest = Interest.find(params[:id])
	
		if @interest.update_attributes(params[:interest])
			flash[:notice] = "Le centre d'intêret a bien été modifié."
	
		else
			render :action => "edit"
		end
		

	end


	def destroy
		@interest = Interest.find(params[:id])
		@interest.destroy

	end
	
	protected
	
	def find_interests
		@interests = Interest.all
	end
	
end
