1

I'm using Ruby on Rails 2.3.8. I've got a vote link that when you click it executes the following action:

def vote
      render :update do |page|
          page.select(".divbrian").each do |d|
            page.replace_html d, "YA SEEE"
          end

          page.select('.d_voting_links_' + params[:post_id].to_s).each do |d|
            page.replace_html d, :partial => 'post_votes/voted'
          end
          page.select('.d_vote_count_' + params[:post_id].to_s).each do |d|
            page.replace_html d, Post.find(params[:post_id]).get_vote_count
          end
      end
end

In the HTML, there are as much divs of class "d_voting_links_" as posts displayed in the html page.

I don't know why, after I've installed Paperclip, Rails TinyMCE, and Hpricot plugins (all of them on the latest version), these ajax requests stopped working (really crazy).

I haven't changed anything of my code, I've even checked on my previous versions in which it works and nothing had changed, but those plugins.

I've also tried to created a simple div and calling it from the same action but it didn't recognize it (it does if I delete the "." from the request, but that will search for IDs, and I need to search for class).

Do you know about any known issue between those plugins and this ajax syntax? Or maybe...do you have a clue about what the problem could be?

Brian Roisentul
  • 4,590
  • 8
  • 53
  • 81
  • Is vote method getting called now? Put a breakpoint and see the flow through that method? – Zabba Nov 17 '10 at 22:36
  • Yes it's. Indeed, the render :update block is being executed...but somehow it does not find any div with that class, eventhough it exists in the HTML...REALLY WEIRD – Brian Roisentul Nov 18 '10 at 15:22
  • No solution, but a tip: `html_escape` the calls to `params[:post_id].to_s` – Zabba Nov 20 '10 at 19:53

1 Answers1

0

I don't know why that block of code stopped working...but I've now figured out that without the page.select block, it will work anyway and replace all of the divs with those class names.

Brian Roisentul
  • 4,590
  • 8
  • 53
  • 81