Observe_form + Check_box = call action? I need help

What I am trying to do is create partial that will be invoked by
a :show_product action under the :admin controller.

This partial is meant to have a list of categories and checkboxes next
to each category. I want to set it up so when someone checks/unchecks
a category, it does something like category.products < self

The models for both Category and Product have a hmabt relationship w/
each other.

The code I’ve got so far is:


<%= render :partial => “categories”, :product => @product %>


<% if @categories %>
<% for category in @categories %>

<% form_for :category, category, :url => { :action => "update_product_category" }, :id => category.id do |f| %> <%= f.check_box :name %><%= f.label category.name %> <% end %>
<% end %>

<% else %>

No categories found.

<% end %>


def categories
@categories = Category.find(:all)

The output from currently is:



  • How do I set up an observe_form or observe_field so that if someone
    clicks on the a checkbox, it calls the action :update_product_category
    and passes it the parameter of @product.id and category.id?
  • Why does the check_box code also produce a hidden field? If I remove
    the check_box code, it doesn’t produce the hidden field any more.
  • What’s up with the authenticity_token?

On Jan 5, 7:50 pm, mel ram [email protected] wrote:

  • Why does thecheck_boxcode also produce a hidden field? If I remove
    thecheck_boxcode, it doesn’t produce the hidden field any more.


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs