Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Rails 7.1. #278

Merged
merged 1 commit into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ gem "pg", "1.5.4"
gem "puma", "6.4.0"
gem "rack-attack", "6.7.0"
gem "rack-timeout", "0.6.3"
gem "rails", "7.0.8"
gem "rails", "7.1.2"
gem "rails-healthcheck", "1.4.0"
gem "redis", "5.0.8"
gem "redis-objects", "1.7.0"
Expand Down
165 changes: 98 additions & 67 deletions Gemfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/forms/session_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class SessionForm < BaseForm
# @return [Account]
def account
if email.present?
@account ||= Account.find_by(email: email.to_s.strip.downcase)
@account ||= Account.find_by(email: email)
end
end

Expand Down
16 changes: 4 additions & 12 deletions app/models/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,17 @@ class Account < ApplicationRecord

has_many :characters, dependent: :destroy

before_create :assign_default_aliases

normalizes :email, with: ->(email) { email.strip.downcase }

validates :email, presence: true,
length: { maximum: MAXIMUM_EMAIL_LENGTH },
format: { with: EMAIL_MATCHER },
uniqueness: { case_sensitive: false }

validates :password, length: { minimum: MINIMUM_PASSWORD_LENGTH }

before_validation :format_attributes
before_create :assign_default_aliases

# Determine if an account can create a character.
#
# @return [Boolean]
Expand All @@ -46,13 +47,4 @@ def can_create_character?
def assign_default_aliases
self.aliases = DEFAULT_ALIASES
end

# Format attributes to be consistent.
#
# * Lowercase and strip the e-mail address.
#
# @return [void]
def format_attributes
self.email = email.to_s.strip.downcase
end
end
5 changes: 4 additions & 1 deletion bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ gem list bundler --installed > /dev/null ||
bundle check || bundle install

# Install the Node dependencies.
yarn check || yarn install
yarn install

# Prepare the database.
./bin/rails db:prepare

# Clean up.
./bin/rails log:clear tmp:clear
8 changes: 5 additions & 3 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
module Miroha
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 7.0
config.load_defaults 7.1

# Add the library directory to the autoload paths.
config.autoload_paths << Rails.root.join("lib")
# Please, add to the `ignore` list any other `lib` subdirectories that do
# not contain `.rb` files, or that should not be reloaded or eager loaded.
# Common ones are `templates`, `generators`, or `middleware`, for example.
config.autoload_lib(ignore: %w(assets middleware tasks))

# Don't generate system test files.
config.generators.system_tests = nil
Expand Down
Loading