class Admin::CustomerRibsController < ApplicationController
  layout "admin"
  

  
  def index
    
    @customer_ribs = CustomerRib.order("created_at DESC").all
  end


  def show

    @customer_rib = CustomerRib.find(params[:id])
    send_file @customer_rib.scan_file.path, :disposition => (params[:inline] ? "inline" : "attachment") if @customer_rib.scan_file?

    
  end
  
  def valid
    @customer_rib = CustomerRib.find(params[:id])
    
    @customer_rib.validated = true
    @customer_rib.validated_at = Time.now
    
    @customer_rib.save
    
    #redirect_to :back
    
  end

  def edit
    @customer_rib = CustomerRib.find(params[:id])
  end


  def update
    @customer_rib = CustomerRib.find(params[:id])
    
    if @customer_rib.update_attributes(params.require(:customer_rib).permit!)

          
    else
      render :action => "edit" 
    end
    
  end

end
