I want to model such a relationship between the User and Event models.

So I started with the following classes:
class User < ActiveRecord::Base ... end class Attendance < ActiveRecord::Base
So far, everything is in order: I can assign users and get access to attendance. But now I want to bring the state into the game, so that I can distinguish, for example, between "present", "without a valid side", ... users. My first attempt was:
class Event < ActiveRecord::Base has_many :attendances has_many :users, :through => :attendances has_many :unexcused_absent_users, -> { where :state => 'unexcused' }, :through => :attendances, :source => :user ... end
(: the source must be specified, because otherwise it will look for membership in an association with the name "unscused_absent_users") The problem here is that the where predicate is evaluated in the "users" table.
I do not know how to solve this βcorrectlyβ without introducing new tables / connection models for each state. Moreover, each user can be in the same state for each event, I think that a solution with one presence model makes sense.
Do you have an idea how to do it right?
source share