Bump rails to 5.2 and update rubocop
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
#
|
||||
# ActiveAdmin console user.
|
||||
#
|
||||
|
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ApplicationRecord < ActiveRecord::Base
|
||||
self.abstract_class = true
|
||||
end
|
||||
|
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
#
|
||||
# A guest or plus one.
|
||||
#
|
||||
|
@ -1,10 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
#
|
||||
# Make a model findable only when a secure token is provided.
|
||||
#
|
||||
module FindableWithToken
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
ID_TOKEN_RX = /\A(\d+)-(\w+)\z/
|
||||
ID_TOKEN_RX = /\A(\d+)-(\w+)\z/.freeze
|
||||
|
||||
included do
|
||||
has_secure_token
|
||||
@ -15,12 +17,14 @@ module FindableWithToken
|
||||
|
||||
def self.find_by_id_token(id_token)
|
||||
raise ActiveRecord::RecordNotFound unless id_token =~ ID_TOKEN_RX
|
||||
|
||||
id = Regexp.last_match(1)
|
||||
token = Regexp.last_match(2)
|
||||
|
||||
record = find(id)
|
||||
raise ActiveRecord::RecordNotFound unless
|
||||
ActiveSupport::SecurityUtils.secure_compare(record.token, token)
|
||||
|
||||
record
|
||||
end
|
||||
end
|
||||
|
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
#
|
||||
# A primary guest.
|
||||
#
|
||||
@ -26,6 +28,7 @@ class Guest < ApplicationRecord
|
||||
def email_safe_salutation
|
||||
return 'Hello,' if
|
||||
first_name.blank? || first_name !~ /\A[\p{Word}\s'-]{1,30}\z/i
|
||||
|
||||
"Dear #{first_name},"
|
||||
end
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
#
|
||||
# An extra guest.
|
||||
#
|
||||
|
Reference in New Issue
Block a user