From 0eeb265fc3fabf9b0eb76864b687cd7240a6962d Mon Sep 17 00:00:00 2001 From: echarp Date: Tue, 22 Dec 2015 00:29:41 +0100 Subject: [PATCH] The default current week is properly recalculated --- app/controllers/digests_controller.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controllers/digests_controller.rb b/app/controllers/digests_controller.rb index 91b19843..4a9641f4 100644 --- a/app/controllers/digests_controller.rb +++ b/app/controllers/digests_controller.rb @@ -2,10 +2,12 @@ class DigestsController < ApplicationController has_scope :moderated, default: nil, allow_blank: true has_scope :region, :locality, :tag - has_scope :period, allow_blank: true, - type: :hash, using: [:year, :week], - default: { year: (Time.zone.today + 7.days).year, - week: (Time.zone.today + 7.days).cweek } + has_scope :period, allow_blank: true, type: :hash, using: [:year, :week], + default: ( + lambda do + { 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_events, only: [:show]