Let's say we have something like:
Logidze.with_responsible(user.id) do
Post.create
end
It would be really useful to be able to find records by their responsible_id:
Post.where(log_data: { responsible_id: user.id })
Otherwise to be able to do this you have to add a real responsible_id column on each of the models and duplicate the with_responsible logic with a slight twist.
Since log_data is JSONB, I think something like this (pseudo-code) is doable, but it requires to know the structure of log_data:
Post.where("(log_data -> 'h' @> '[r ->> ?]')", user.id)
Let's say we have something like:
It would be really useful to be able to find records by their
responsible_id:Otherwise to be able to do this you have to add a real
responsible_idcolumn on each of the models and duplicate thewith_responsiblelogic with a slight twist.Since
log_datais JSONB, I think something like this (pseudo-code) is doable, but it requires to know the structure oflog_data: