Tomas -
An *option* I've used in the past is to add a datetime field such as "dropped_at" that defaults to null to your memberships table.
From there, you could add a scope to the memberships model like:
class Membership < ActiveRecord::Base
scope :active, -> { where(dropped_at: nil) }
end
This concept used to be used when you wanted to "soft delete" a record from your table,
but have an option to "undo" the delete. Here, in your instance - you can borrow the idea
to easily find those memberships for a given User that are "active" as well as those users
that are currently a part of a group. The standard created_at field that is on the memberships
table can be used to indicate when a user joined a group.
Hope this helps!
Mike