ruby on rails - How to delete an object of a has_many where the parent object is not yet saved -


I have a @activity that_im: Clientship

When I create a new object I have several clients object But before saving, the user wants to pick something to remove.

How do I delete the following clientpoint objects based on user-defined client_id?

The archive looks like:

  @ activity.clientships [# & lt; Clientship ID: Zero; Client_ID: 1770 & gt;, # & lt; Clientship ID: Zero; Client_ID: 24 & gt ;, # & lt; Clientship ID: Zero; Client_ID: 25>, # & lt; Clientship ID: Zero, Client_ID: 2181, & gt; ]  

I tried the example code which was not working (not to mention ineligible):

  @ activity.clientships.map {| O | If o.delete o.client_id == 24}  

  @ activation clienships .delete_if {| O | O.client_id == 24}  

Comments