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:
show_product.rhtml
<%= render :partial => “categories”, :product => @product %>
_categories.rhtml
<% if @categories %>
<% for category in @categories %>
<% else %>
No categories found.
<% end %>admin_controller.rb
def categories
@categories = Category.find(:all)
end
The output from currently is:
QUESTIONS:
- 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?