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

Eagerload on application boot #2289

Merged
merged 2 commits into from
Oct 11, 2018
Merged

Eagerload on application boot #2289

merged 2 commits into from
Oct 11, 2018

Conversation

f-mer
Copy link

@f-mer f-mer commented Oct 8, 2018

Purpose

Load all modules and classes during application boot. This is needed because rails 5 unhooks autoloading (rails/rails@a71350c) after the application has booted.

Changes

Eagerload dependencies during application boot by using eager_autoload.

Related GitHub issues

#2255

Additional helpful information

Not sure if eagerloading ActiveModelSerializers::Adapter::JsonApi should be the default or the user has to add explicitly config.eager_load_namespaces << ActiveModelSerializers::Adapter::JsonApi to reduce memory usage if another adapter is used.

@bf4
Copy link
Member

bf4 commented Oct 8, 2018

Looks good. Looks like there was a change in minitest run_one_method

/home/travis/build/rails-api/active_model_serializers/vendor/bundle/ruby/2.2.0/gems/minitest-5.11.3/lib/minitest.rb:961:in `run_one_method': RailtieTest::WithRailsRequiredFirst#run _must_ return a Result (RuntimeError)
	from /home/travis/build/rails-api/active_model_serializers/vendor/bundle/ruby/2.2.0/gems/minitest-5.11.3/lib/minitest/parallel.rb:33:in `block (2 levels) in start'
rake aborted!

@f-mer
Copy link
Author

f-mer commented Oct 9, 2018

@bf4 thanks for taking a look at it. Seems like there happend some backwards incompatible change in minitest unreleated to this PR. This issue rails/rails-perftest#43 seems to be releated.

@bf4
Copy link
Member

bf4 commented Oct 11, 2018

I've fixed CI. might rebasing and re-running CI?

f-mer added 2 commits October 11, 2018 21:32
Using ActiveModelSerializers with a threaded web server eg. Puma
uninitialized constant errors are thrown. Leaving this article for
reference:
http://blog.plataformatec.com.br/2012/08/eager-loading-for-greater-good/.
@f-mer
Copy link
Author

f-mer commented Oct 11, 2018

Yay it's green 🎉
Thanks for fixing the ci pipeline 👍

@bf4 bf4 merged commit 65313b9 into rails-api:0-10-stable Oct 11, 2018
@bf4
Copy link
Member

bf4 commented Oct 11, 2018

@f-mer merged!

would you be interested in looking at #2223 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants