Hi everyone,

I am having a problem rendering js, this is my code:

in the main view index.html.erb I have

<div id="poll">
        <%= render(:partial => 'poll')%>
</div>

In the partial _poll.html.erb I have:
<%= form_tag(:action => "update_all", :remote => true) do %>

  <% for @poll in @polls %>
    <p>
    <%= fields_for @poll do |f| %>
            <%= f.check_box (:selected, "index" => @poll.id) %>
                        <%= @poll.name  %>
                        <%= @poll.votes  %>
    <% end %>
    </p>
  <% end %>
  <p>
      <%= submit_tag "Update" %>
  </p>
<% end %>

The method in the controller looks like this:

  def update_all
    params[:poll].each do |id, attr|

      poll = Poll.find(id)

      if (attr['selected'] == "1")

        poll.votes = poll.votes + 1
        poll.save
      end
    end

    respond_to do |format|
      format.html { redirect_to(stipso_path) }
      format.js
    end
  end

I have a file called update_all.js.rjs which I think it is supposed to
be called from the controller but it is ignored because html is
processed instead.

I basically want to replace the poll content using AJAX.

Here is the log msg from the rails s console:

Started POST "/foo/update_all?remote=true" for 127.0.0.1 at Wed Jun 08
21:09:13 +0100 2011
  Processing by FooController#update_all as HTML

What am I doing wrong?

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to