class Public::AnnonceAccountFavsController < ApplicationController layout "public" def new @annonce = Annonce.find(params[:annonce_id]) if current_annonce_account if current_annonce_account.annonce_favs.where(:id => params[:annonce_id].to_i).count > 0 current_annonce_account.annonce_favs.delete(@annonce) else current_annonce_account.annonce_favs << @annonce end end end end