It works! Thanks! stupid brackets... :-) On Jun 9, 12:20 am, pipplo <[email protected]> wrote: > I think your form is not setting remote correctly. > > If it was submitting correctly you should not see ?remote=true. > > form tag takes 2 parameters url_for_options and options. If you don't > put the {} around the first set of options it will assume they are all > url_for_options > > form_tag(url_for_options = {}, options = {}, *parameters_for_url, > &block) > > Basically I think you need to change your form tag to look like this > > <%= form_tag({:action => "update_all"}, :remote => true) do %> > > On Jun 8, 1:18 pm, johnlucas <[email protected]> wrote: > > > > > > > > > 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.

