Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

No, it is not impossible to delete objects provided by ActiveRecordAssociationsCollectionProxy.

You can delete the objects by calling the destroy method on the ActiveRecord_Associations_CollectionProxy object or by calling the destroy_all method on the associated objects.

For example:

# assuming you have a has_many association between User and Post
user = User.first
posts = user.posts # posts is an ActiveRecord_Associations_CollectionProxy object

# deleting a specific object
post = posts.first
post.destroy

# deleting all objects
posts.destroy_all

It's important to note that deleting objects using these methods will also delete any associated objects that depend on them.