diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-09-25 01:45:31 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-25 01:45:31 +0900 |
commit | 06274428e534f8e12fc7d6904a89678b23c5b404 (patch) | |
tree | 20e710493a17f143e8a91fff9889fd4b62904be4 /activerecord | |
parent | d03cc170c1bdad15245be7f2681a265fd2bd0d5d (diff) | |
parent | 3b954786e7876ad63c917ed1dae310624c8ccf33 (diff) | |
download | rails-06274428e534f8e12fc7d6904a89678b23c5b404.tar.gz rails-06274428e534f8e12fc7d6904a89678b23c5b404.tar.bz2 rails-06274428e534f8e12fc7d6904a89678b23c5b404.zip |
Merge pull request #33959 from eugeneius/eager_load_attribute_methods
Eagerly define attribute methods in production
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/railtie.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/railtie.rb b/activerecord/lib/active_record/railtie.rb index 812fecbf32..81ad9ef3a2 100644 --- a/activerecord/lib/active_record/railtie.rb +++ b/activerecord/lib/active_record/railtie.rb @@ -137,6 +137,14 @@ end_error end end + initializer "active_record.define_attribute_methods" do |app| + config.after_initialize do + ActiveSupport.on_load(:active_record) do + descendants.each(&:define_attribute_methods) if app.config.eager_load + end + end + end + initializer "active_record.warn_on_records_fetched_greater_than" do if config.active_record.warn_on_records_fetched_greater_than ActiveSupport.on_load(:active_record) do |