class Admin::PortfoliosController < ApplicationController
  layout "admin"
  
  before_filter :auth_admin
  
  def index
    
    @portfolios = Portfolio.all
  end


  def show
    @portfolio = Portfolio.find(params[:id])

  end


  def new
    @portfolio = Portfolio.new
  
  end

  def edit
    @portfolio = Portfolio.find(params[:id])
  
  end

  def create
  	@portfolio = Portfolio.new(portfolio_params)
    
    if @portfolio.save
      @portfolios = Portfolio.all
          
  	else
  		render :action => "new" 
  	end
  end

  def update
  	@portfolio = Portfolio.find(params[:id])
    
    if @portfolio.update_attributes(portfolio_params)

          
  	else
  		render :action => "edit" 
  	end
    
  end
  		


  def destroy
  	@portfolio = Portfolio.find(params[:id])
	  
    @portfolio.destroy
  
  end
  
  private
      def portfolio_params
        params.require(:portfolio).permit(:title, :description)
      end



end
