Ruby on Rails - problems with the Ajax response

I having trouble with an Ajax response in Rails and I don't know how to go about debugging it.

This code works as expected:


 <div id="<%= dom_id(comment) %>_count">
   <%= Like.where("comment_id = ?", %>

.js.erb response

 $("#<%= dom_id(@comment) %>_count").html("<%= Like.where('comment_id = ?', %>");

However, if I add in a link_to, the response stops working. Any help on what might be going on would be greatly appreciated.


 <div id="<%= dom_id(comment) %>_count">
   <%= link_to Like.where("comment_id = ?",, "#" %>

.js.erb response

 $("#<%= dom_id(@comment) %>_count").html("<%= link_to Like.where('comment_id = ?',, "#" %>");


Your Like.where(...).count call will return an integer from the .count method, which will give you the HTML:

<a href="/">1</a>

Which is equivalent to with the visual label 1. This link will point to your app's root path.

Is that what you intend?

Need Your Help

How to host a wordpress blog from a domain pointed to an app hosted with google app engine?

wordpress google-app-engine dns a-records

I have a Python web app hosted with Google App Engine with a .com pointed towards the App Engine app. I would like to start a Wordpress blog at

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.