I'm trying to implement a voting system kind of like the one here on Stack Overflow. (Using Rails 3) I want the voting to be done without a page reload, so I have this code
link_to("/tags/#{tag.id}/upVote", :remote => true )
And so in my /views/tags directory I have a file called _upVote.js.erb that I thought would be called when this link is clicked, but it is not. It is trying to process upVote as HTML and this is the error I get
Missing template tags/upVote with {:formats=>[:html]
Also, here is what I have in my routes file
match "tags/:id/upVote" => "tags#upVote"
Any ideas how I can get this to work?
If you got this error message in a blank new page, that means that your remote call does not work and the call wasn't made via an Ajax request. You need to check that your layout correctly loads jQuery and the jQuery Rails connector available here : http://github.com/rails/jquery-ujs
Then use Firefox+Firebug to check that the call is really an Ajax call.
I had this same problem. To resolve the problem, I followed
And finally, I had to
Require both jquery and jquery_ujs were in the application.js manifest.
//= require jquery
//= require jquery_ujs
After all that, Rails ajax started working for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With