Let's say I have two models, Post
and Comment
and the comment model can be 1 out of 2 types, normal
and fancy
which is defined by the column type
in the comments
table.
Now I want to add 2 associations on my Post
model, where one refers to fancy comments and one to normal ones, how would I do it? So I want something like this:
has_many :fancy_comments, MyApp.Comment, where: [type: 0]
has_many :normal_comments, MyApp.Comment, where: [type: 1]
where
but something for filtering in general? – Bisitun