Bump rails to 5.2 and update rubocop
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
ActiveAdmin.register AdminUser do
|
||||
permit_params :email, :password, :password_confirmation
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
ActiveAdmin.register Attendee do
|
||||
scope :child?
|
||||
scope :diet?
|
||||
|
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
ActiveAdmin.register_page 'Dashboard' do
|
||||
menu priority: 1, label: proc { I18n.t('active_admin.dashboard') }
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
ActiveAdmin.register Guest do
|
||||
permit_params :email, :first_name, :last_name, :attending, :diet, :songs,
|
||||
:notes
|
||||
|
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
ActiveAdmin.register PlusOne do
|
||||
permit_params :first_name, :last_name, :diet, :child
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ApplicationController < ActionController::Base
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class GuestsController < ApplicationController
|
||||
def new
|
||||
respond_to :html
|
||||
|
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class PlusOnesController < ApplicationController
|
||||
before_action do
|
||||
@guest = Guest.find_by_id_token(params[:guest_id])
|
||||
@ -41,7 +43,7 @@ class PlusOnesController < ApplicationController
|
||||
def destroy
|
||||
respond_to :html
|
||||
@plus_one = @guest.plus_ones.find_by(id: params[:id])
|
||||
@plus_one.destroy if @plus_one
|
||||
@plus_one&.destroy
|
||||
redirect_to guest_plus_ones_path(@guest)
|
||||
end
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class WelcomeController < ApplicationController
|
||||
def index
|
||||
@google_maps_url = 'https://goo.gl/maps/nBAxNAsmPSS2'
|
||||
|
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module ApplicationHelper
|
||||
def flash_class(key)
|
||||
case key
|
||||
@ -10,6 +12,7 @@ module ApplicationHelper
|
||||
|
||||
def errors_for(object)
|
||||
return unless object.errors.any?
|
||||
|
||||
content_tag(:div, class: 'mb-3 card border-danger') do
|
||||
concat(content_tag(:div, class: 'card-header bg-danger text-white') do
|
||||
concat "Oops, #{pluralize(object.errors.count, 'problem')}:"
|
||||
|
@ -1,2 +1,4 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module GuestsHelper
|
||||
end
|
||||
|
@ -1,2 +1,4 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module PlusOnesHelper
|
||||
end
|
||||
|
@ -1,2 +1,4 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module WelcomeHelper
|
||||
end
|
||||
|
@ -1,2 +1,4 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ApplicationJob < ActiveJob::Base
|
||||
end
|
||||
|
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ApplicationMailer < ActionMailer::Base
|
||||
default from: 'from@example.com'
|
||||
layout 'mailer'
|
||||
|
@ -1,3 +1,5 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class GuestMailer < ApplicationMailer
|
||||
default from: ENV['FROM_EMAIL'], reply_to: ENV['CONTACT_EMAIL']
|
||||
|
||||
|
@ -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