I am using ajax to call a RoR rails function and am new to this.
The function is
def destroy
@fav_company = FavouriteCompany.find(params[:id])
respond_to do |format|
format.js { render :layout=>false }
end
end
In my destroy.js.erb I have
$('#profile_alerts').show();
$('#Fav#{@fav_company.id}').hide();
The first line is working but not the second line. I am suspecting it is unable to access @fav_company.
What should I do? thanks
=====
Some additional information, the call I am making to this function is a link_to with remote => 'true' as such:
<%=link_to "destroy",{:controller=>"favourite_companies",:action=>"destroy", :id=>"#{fav.id}"}, {:remote => true } %>