The default current week is properly recalculated

This commit is contained in:
echarp 2015-12-22 00:29:41 +01:00
parent 0d63f2bb57
commit 0eeb265fc3

View File

@ -2,10 +2,12 @@
class DigestsController < ApplicationController class DigestsController < ApplicationController
has_scope :moderated, default: nil, allow_blank: true has_scope :moderated, default: nil, allow_blank: true
has_scope :region, :locality, :tag has_scope :region, :locality, :tag
has_scope :period, allow_blank: true, has_scope :period, allow_blank: true, type: :hash, using: [:year, :week],
type: :hash, using: [:year, :week], default: (
default: { year: (Time.zone.today + 7.days).year, lambda do
week: (Time.zone.today + 7.days).cweek } { year: (Time.zone.today + 7.days).year,
week: (Time.zone.today + 7.days).cweek }
end)
before_action :set_week, if: -> { params[:period] } before_action :set_week, if: -> { params[:period] }
before_action :set_events, only: [:show] before_action :set_events, only: [:show]