Display last milestones image
Also adds a second order to ensure the order to display milestones with same publication date is always the same
This commit is contained in:
@@ -7,8 +7,8 @@ module BudgetExecutionsHelper
|
||||
end
|
||||
|
||||
def first_milestone_with_image(investment)
|
||||
investment.milestones.order(publication_date: :asc, created_at: :asc)
|
||||
.select{ |milestone| milestone.image.present? }.first
|
||||
investment.milestones.order_by_publication_date
|
||||
.select{ |milestone| milestone.image.present? }.last
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -17,7 +17,7 @@ class Budget
|
||||
validates :publication_date, presence: true
|
||||
validate :description_or_status_present?
|
||||
|
||||
scope :order_by_publication_date, -> { order(publication_date: :asc) }
|
||||
scope :order_by_publication_date, -> { order(publication_date: :asc, created_at: :asc) }
|
||||
scope :published, -> { where("publication_date <= ?", Date.current) }
|
||||
scope :with_status, -> { where("status_id IS NOT NULL") }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user