Ahoy, i’m trying to save a many to many between “talent” and “vital
stat”
talent_controller.rb
def edit
@talent = Talent.find(params[:id], :include => [:talent_type,
:vital_stats])
@talent_types = TalentType.find_all
@vital_stats = VitalStat.find_all
if request.post?
@talent.attributes = params[:talent]
@talent.attributes = params[:talent_type]
if @talent.update_attributes(params[:vital_stat][:id])
flash[:notice] = 'Talent was successfully updated.'
end
end
end
def delete
Form fields for checkboxes
Select Vital Stats<% VitalStat.find(:all).each do |g| %>
<%= form_bit_checkbox('vital_stat', g.id, g.title, '', '',
@talent.vital_stats.include?(g) ? {‘checked’ => ‘checked’} : ‘’) %>
<% end %>
My problem is that the talent isn’t being updated w/ the checked or
unchecked fields. The returned PARAMS could look like this:
commit: Save
action: edit
talent: !map:HashWithIndifferentAccess
title: Casting Director
id: “2”
talent_type: !map:HashWithIndifferentAccess
talent_type_id: “1”
controller: talent
vital_stat: !map:HashWithIndifferentAccess
“2”: “0”
“3”: “0”
“4”: “1”
which means there are three checkboxes, the last being checked - but my
talent always shows all 3 as checked (meaning its not updating the fact
that they are currently unchecked)
Any help?