class Public::AnnonceAccountRibsController < ApplicationController
  layout "public"
  
  before_filter :auth_annonce_account
  

  
  def index


    
    @annonce_account_ribs = current_annonce_account.annonce_account_ribs.all
    
    
  end


  def show
    @annonce_account_rib = AnnonceAccountRib.find(params[:id])
    session[:mail_prev] = public_annonce_account_rib_path(@annonce_account_rib)
  end


  def new
    @no_search = true
    @annonce_account_rib = current_annonce_account.annonce_account_ribs.new(:country => "France")
    
    
  end

  def edit
    @annonce_account_rib = current_annonce_account_rib_account.annonce_account_ribs.find(params[:id])
  
  end



  def create

    
  	@annonce_account_rib = current_annonce_account.annonce_account_ribs.new(params.require(:annonce_account_rib).permit!)

    
    
    
    if @annonce_account_rib.save
      
      
      redirect_to public_annonce_account_ribs_path
      

          
  	else
  		render :action => "new" 
  	end
  end

  
  def update
    @annonce_account_rib = current_annonce_account.annonce_account_ribs.find(params[:id])
   
    

    
    respond_to do |format|
      if @annonce_account_rib.update_attributes(params.require(:annonce_account_rib).permit!)



        format.html { 
          redirect_to public_my_account_path
          }
        format.js
        
      else
        
        format.html { render :action => "edit" }
        format.js { "" }
      end
    end
    
    
      
  end
  		


  def destroy

    	 @annonce_account_rib = current_annonce_account_rib_account.annonce_account_ribs.find(params[:id])
  	   @annonce_account_rib.enabled = nil
       @annonce_account_rib.save
       
       redirect_to public_my_account_path, :notice => "Votre annonce_account_rib a bien été désactivée"

    

  end



end
