On Wednesday, June 3, 2015 at 10:06:58 AM UTC-7, ivan sisovic wrote:
>
> When there is many_to_many association between Books and Users
>
> What is the best way (fastest) to delete all Users with no books. 
>

Probably something like this:

  User.exclude(:id=>DB[:books_users].select(:user_id)).delete 

Basically, delete all users that don't have an entry in the join table.

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to