Skip to content

Commit

Permalink
Adopt some new APIs from Rails 7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
aidewoode committed Nov 7, 2023
1 parent eb4221e commit cfc31b6
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 74 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Expand Up @@ -30,7 +30,7 @@ RUN bundle config --local without 'development test' \

COPY . /app

RUN bundle exec rails assets:precompile SECRET_KEY_BASE=fake_secure_for_compile \
RUN SECRET_KEY_BASE_DUMMY=1 bundle exec rails assets:precompile \
&& yarn cache clean \
&& rm -rf node_modules tmp/cache/* /tmp/* yarn.lock log/production.log app/javascript/* app/assets/*

Expand Down
9 changes: 0 additions & 9 deletions app/controllers/health_controller.rb

This file was deleted.

7 changes: 2 additions & 5 deletions app/models/user.rb
Expand Up @@ -11,10 +11,11 @@ class User < ApplicationRecord
has_setting :theme, default: DEFAULT_THEME
serialize :recently_played_album_ids, type: Array, coder: YAML

before_create :downcase_email
before_update :remove_deprecated_password_salt, if: :will_save_change_to_password_digest?
after_create :create_buildin_playlists

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

validates :email, presence: true, format: {with: URI::MailTo::EMAIL_REGEXP}, uniqueness: {case_sensitive: false}
validates :password, allow_nil: true, length: {minimum: 6}
validates :theme, inclusion: {in: AVAILABLE_THEME_OPTIONS}, allow_nil: true
Expand Down Expand Up @@ -66,8 +67,4 @@ def create_buildin_playlists
create_current_playlist
create_favorite_playlist
end

def downcase_email
self.email = email.downcase
end
end
14 changes: 6 additions & 8 deletions config/puma.rb
Expand Up @@ -23,12 +23,12 @@
# Specifies the `pidfile` that Puma will use.
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }

# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked web server processes. If using threads and workers together
# the concurrency of the application would be max `threads` * `workers`.
# Workers do not work on JRuby or Windows (both of which do not support
# processes).
# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
# Specifies that the worker count should equal the number of processors in production.
if ENV["RAILS_ENV"] == "production"
require "concurrent-ruby"
worker_count = Integer(ENV.fetch("WEB_CONCURRENCY") { Concurrent.physical_processor_count })
workers worker_count if worker_count > 1
end

# Use the `preload_app!` method when specifying a `workers` number.
# This directive tells Puma to first boot the application and load code
Expand All @@ -41,8 +41,6 @@
plugin :tmp_restart

if BlackCandy::Config.embedded_sidekiq?
workers 2

# Preloading the application is necessary to ensure
# the configuration in your initializer runs before
# the boot callback below.
Expand Down
4 changes: 1 addition & 3 deletions config/routes.rb
Expand Up @@ -68,9 +68,7 @@
get "/422", to: "errors#unprocessable_entity", as: :unprocessable_entity
get "/500", to: "errors#internal_server_error", as: :internal_server_error

# Rails 7.1 will support health check by default,
# So we will replace this route with the default one in the future.
get "/up", to: "health#show"
get "up", to: "rails/health#show", as: :rails_health_check

namespace :api do
namespace :v1 do
Expand Down
5 changes: 2 additions & 3 deletions docker/production_start.sh
@@ -1,5 +1,4 @@
#!/bin/sh

rails docker:db_prepare

bundle exec puma -C config/puma.rb
rails db:prepare
bundle exec puma -C config/puma.rb
22 changes: 0 additions & 22 deletions lib/tasks/docker.rake

This file was deleted.

23 changes: 0 additions & 23 deletions test/controllers/health_controller_test.rb

This file was deleted.

0 comments on commit cfc31b6

Please sign in to comment.