Skip to content

Instantly share code, notes, and snippets.

View vast's full-sized avatar
🏠
Working from home

Vasily Polovnyov vast

🏠
Working from home
View GitHub Profile
scope :complete, ->(value) { where(summary_status: 'complete', state: 'active').limit(value) }
scope :accessible_by_user, ->(user) do
includes(:assignee_tasks)
.where('tasks.user_id = :user_id OR assignee_tasks.user_id = :user_id', user_id: user.id)
end
scope :accessible_by_user_with_state, ->(user, state) do
accessible_by_user(user).where('tasks.state = :state OR assignee_tasks.state = :state', :state)
end