On Dec 9, 12:10 pm, tecregio <[EMAIL PROTECTED]> wrote:
> I have a problem related with the HABTM relationships with checkboxes.
>
> I've got a profile and a service model, both related with
> has_and_belongs_to_many.
>
> The problem is that i can insert new data in the profiles_services
> table, however, i cant delete already existing data.
>
> What could be the problem?

Try putting this ProfilesController#update , before #update_attributes
is called:
  params[:profile][:service_ids] ||= []

And put this in ServicesController#update , before #update_attributes
is called:
  params[:service][:profile_ids] || = []

These are needed because forms don't submit values for unticked
checkboxes. If you watch the "HABTM Checkboxes" RailsCast, you'll
learn more about this:
http://railscasts.com/episodes/17-habtm-checkboxes

Cheers,
Nick
--~--~---------~--~----~------------~-------~--~----~
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