Files
grecia/app/models/dashboard/administrator_task.rb
Javi Martín 38ad65605e Use excluding instead of where.not(id:
This method was added in Rails 7.0 and makes the code slihgtly more
readable.

The downside is that it generates two queries instead of one, so it
might generate some confusion when debugging SQL queries. Its impact on
performance is probably negligible.
2024-07-22 18:35:35 +02:00

16 lines
365 B
Ruby

class Dashboard::AdministratorTask < ApplicationRecord
belongs_to :source, polymorphic: true
belongs_to :user
validates :source, presence: true
default_scope { order(created_at: :asc) }
scope :done, -> { where.not(executed_at: nil) }
scope :pending, -> { excluding(done) }
def title
"#{source.proposal.title} #{source.action.title}"
end
end