From fee5d9384862af086613c4f09e0fd96f7bd347b8 Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Tue, 3 Jun 2014 11:19:21 +0100 Subject: Add cache-busting to request response notification Users get a new response email, click the link, but get a cached page. This is a quick fix to ensure they always see the response when clicking the link. --- app/helpers/link_to_helper.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'app/helpers/link_to_helper.rb') diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb index dd6ffa805..9f63ec583 100755 --- a/app/helpers/link_to_helper.rb +++ b/app/helpers/link_to_helper.rb @@ -28,7 +28,9 @@ module LinkToHelper # Incoming / outgoing messages def incoming_message_url(incoming_message, options = {}) - return request_url(incoming_message.info_request, options.merge(:anchor => "incoming-#{incoming_message.id}")) + default_options = { :anchor => "incoming-#{ incoming_message.id }", + :nocache => "incoming-#{ incoming_message.id }" } + request_url(incoming_message.info_request, options.merge(default_options)) end def incoming_message_path(incoming_message) @@ -36,7 +38,9 @@ module LinkToHelper end def outgoing_message_url(outgoing_message, options = {}) - request_url(outgoing_message.info_request, options.merge(:anchor => "outgoing-#{outgoing_message.id}")) + default_options = { :anchor => "outgoing-#{ outgoing_message.id }", + :nocache => "outgoing-#{ outgoing_message.id }" } + request_url(outgoing_message.info_request, options.merge(default_options)) end def outgoing_message_path(outgoing_message) -- cgit v1.2.3 From 6bd0bfe7599aee4e55bdd63196d1e2c5cc80129c Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Tue, 3 Jun 2014 12:34:00 +0100 Subject: Remove duplication from new correspondence urls --- app/helpers/link_to_helper.rb | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'app/helpers/link_to_helper.rb') diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb index 9f63ec583..e5ef2ca39 100755 --- a/app/helpers/link_to_helper.rb +++ b/app/helpers/link_to_helper.rb @@ -28,23 +28,19 @@ module LinkToHelper # Incoming / outgoing messages def incoming_message_url(incoming_message, options = {}) - default_options = { :anchor => "incoming-#{ incoming_message.id }", - :nocache => "incoming-#{ incoming_message.id }" } - request_url(incoming_message.info_request, options.merge(default_options)) + message_url(incoming_message, options) end def incoming_message_path(incoming_message) - incoming_message_url(incoming_message, :only_path => true) + message_path(incoming_message) end def outgoing_message_url(outgoing_message, options = {}) - default_options = { :anchor => "outgoing-#{ outgoing_message.id }", - :nocache => "outgoing-#{ outgoing_message.id }" } - request_url(outgoing_message.info_request, options.merge(default_options)) + message_url(outgoing_message, options) end def outgoing_message_path(outgoing_message) - outgoing_message_url(outgoing_message, :only_path => true) + message_path(outgoing_message) end def comment_url(comment, options = {}) @@ -352,5 +348,24 @@ module LinkToHelper return url_for(params) end + private + + # Private: Generate a request_url linking to the new correspondence + def message_url(message, options = {}) + message_type = message.class.to_s.gsub('Message', '').downcase + + default_options = { :anchor => "#{ message_type }-#{ message.id }" } + + if options.delete(:cachebust) + default_options.merge!(:nocache => "#{ message_type }-#{ message.id }") + end + + request_url(message.info_request, options.merge(default_options)) + end + + def message_path(message) + message_url(message, :only_path => true) + end + end -- cgit v1.2.3 From 77ce9b795c62d8241b22878cf60ca688fa4b44a1 Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Tue, 3 Jun 2014 11:35:55 +0100 Subject: Move date helpers to DateTimeHelper --- app/helpers/link_to_helper.rb | 62 ------------------------------------------- 1 file changed, 62 deletions(-) (limited to 'app/helpers/link_to_helper.rb') diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb index e5ef2ca39..3709469cf 100755 --- a/app/helpers/link_to_helper.rb +++ b/app/helpers/link_to_helper.rb @@ -279,68 +279,6 @@ module LinkToHelper end end - # Public: Usually-correct format for a DateTime-ish object - # To define a new new format define the `simple_date_{FORMAT}` method - # - # date - a DateTime, Date or Time - # opts - a Hash of options (default: { format: :html}) - # :format - :html returns a HTML