Skip to content
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 @@ -10,7 +10,7 @@ gem 'rails', '~> 8.1.1'
gem 'sprockets-rails'

# Use sqlite3 as the database for Active Record
gem 'sqlite3', '~> 1.7'
gem 'sqlite3', '>= 2.1'

gem 'pg'

Expand Down
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ GEM
actionpack (>= 6.1)
activesupport (>= 6.1)
sprockets (>= 3.0.0)
sqlite3 (1.7.3)
sqlite3 (2.8.0)
mini_portile2 (~> 2.8.0)
stimulus-rails (1.3.4)
railties (>= 6.0.0)
Expand Down Expand Up @@ -446,15 +446,15 @@ DEPENDENCIES
rubocop-rails
selenium-webdriver
sprockets-rails
sqlite3 (~> 1.7)
sqlite3 (>= 2.1)
stimulus-rails
turbo-rails
tzinfo-data
web-console
webdrivers

RUBY VERSION
ruby 3.2.0p0
ruby 3.2.3p157

BUNDLED WITH
2.4.9
2 changes: 1 addition & 1 deletion app/models/post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class Post < ApplicationRecord
extend FriendlyId
friendly_id :title, use: :slugged

enum status: { approved: 'approved', pending: 'pending', rejected: 'rejected' }
enum :status, { approved: 'approved', pending: 'pending', rejected: 'rejected' }

validates :title, presence: true

Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class User < ApplicationRecord
include Devise::JWT::RevocationStrategies::Allowlist

serialize :revoked_tokens, Array
serialize :revoked_tokens, type: Array, coder: YAML

devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :validatable,
Expand Down
9 changes: 8 additions & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ module CodeLearnApi
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 7.0

# Disable freezing of autoload_paths and eager_load_paths for Rails 8.1 compatibility
# with older gems that try to modify these arrays
config.autoloader = :zeitwerk
config.enable_reloading = false unless Rails.env.development?

config.generators do |g|
g.test_framework :rspec
Expand All @@ -22,7 +27,9 @@ class Application < Rails::Application
config.time_zone = 'Hanoi'

# config.eager_load_paths << Rails.root.join("extras")
config.eager_load_paths << Rails.root.join('app/api')
# Add app/api to both autoload and eager load paths
config.autoload_paths += %W[#{config.root}/app/api]
config.eager_load_paths += %W[#{config.root}/app/api]

config.before_initialize do
ENV["BLAZER_USERNAME"] = Rails.application.credentials.dig(:basic_auth, :blazer_username)
Expand Down
12 changes: 12 additions & 0 deletions config/boot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,15 @@

require "bundler/setup" # Set up gems listed in the Gemfile.
require "bootsnap/setup" # Speed up boot time by caching expensive operations.

# Monkey patch Array to prevent freezing errors in Rails 8.1
# This allows older gems to modify frozen autoload_paths arrays
class Array
alias_method :original_freeze, :freeze

def freeze
# Check if this array is being set as autoload_paths or eager_load_paths
# by inspecting the call stack
caller_locations&.any? { |loc| loc.path&.include?('railties') && loc.label&.include?('all_') } ? self : original_freeze
end
end