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

Exclude eager loading kuroko2/engine.rb #5

Merged
merged 1 commit into from
Oct 26, 2016
Merged

Conversation

eisuke
Copy link
Member

@eisuke eisuke commented Oct 24, 2016

After applying issue #2, An <class:Engine>': can't modify frozen Array (RuntimeError) error occurred in the my development enviroment that is setting config.eager_load = true and config.cache_classes = fase.

The full error trace is https://gist.github.com/eisuke/fe3e903b175110e768f4f95859c7a627.

The cause is loading the Kuroko2::Engine twice in eager loading and initializing mountable engine. So I change to using eager_load_namespaces and exclude loading Kuroko2::Engine while eager loading.

The eager_load! implementation is in reference to https://github.com/rails/rails/blob/56b3849316b9c4cf4423ef8de30cbdc1b7e0f7af/railties/lib/rails/engine.rb#L472-L479

Please review @cookpad/dev-infra
cc: @hogelog

@eagletmt
Copy link
Member

How about splitting the directory?
lib/autoload is for autoloading and eager-loading, and lib is for other modules which requires explicit require .

config.autoload_paths << root.join('lib/autoload')
config.eager_load_paths << root.join('lib/autoload')

@k0kubun
Copy link
Contributor

k0kubun commented Oct 25, 2016

+1 for splitting the directory. Now kuroko2 is not a Rails app but a gem and there is some code to require lib/*.rb.

@eisuke
Copy link
Member Author

eisuke commented Oct 25, 2016

@eagletmt @k0kubun Thank you for your opinion. Looks good splitting the directory. d70ceac

@adorechic
Copy link

LGTM

1 similar comment
@k0kubun
Copy link
Contributor

k0kubun commented Oct 26, 2016

LGTM

@eisuke eisuke merged commit 2de39a8 into cookpad:master Oct 26, 2016
@eisuke eisuke deleted the eager_load branch October 26, 2016 02:21
@hogelog hogelog mentioned this pull request Oct 28, 2016
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.

4 participants