Skip to content

Commit

Permalink
Redefine table_name_prefix out of ActiveRecord on load hook
Browse files Browse the repository at this point in the history
A previous patch introduced a regression where the table_name_prefix would always be overriden and always return the engine's name as prefix.
  • Loading branch information
hubb committed Feb 27, 2024
1 parent 08e0f8d commit a72850b
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions railties/lib/rails/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -395,13 +395,7 @@ def isolate_namespace(mod)
define_method(:railtie_namespace) { railtie }

unless mod.respond_to?(:table_name_prefix)
define_method(:table_name_prefix) { "#{name}_" }

ActiveSupport.on_load(:active_record) do
mod.singleton_class.redefine_method(:table_name_prefix) do
"#{ActiveRecord::Base.table_name_prefix}#{name}_"
end
end
define_method(:table_name_prefix) { "#{ActiveRecord::Base.table_name_prefix}#{name}_" }
end

unless mod.respond_to?(:use_relative_model_naming?)
Expand Down

0 comments on commit a72850b

Please sign in to comment.