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

Guard against assets not being configured #303

Merged
merged 1 commit into from
Dec 29, 2015

Conversation

clupprich
Copy link
Contributor

The change in #277 unfortunately breaks Rails applications in API mode (Rails 5 or via the rails-api gem): When configuring an application API only, the Rails.application.config.assets entry isn't available and the RequestStrategy middleware crashes the application. This now checks if the application is running on api-only mode and does the test for the assets-path afterwards.

@pyromaniac
Copy link
Contributor

Why don't check Rails.application.config.assets entry itself here? It will be more clear I suppose

@clupprich
Copy link
Contributor Author

I tried that, but that's hidden behind some method_missing magic.

@clupprich
Copy link
Contributor Author

Also tried the usual suspects like #key?, and checked the documentation, but seems that you can't query if a config entry exists. We could try a respond_to, however.

@clupprich
Copy link
Contributor Author

@pyromaniac I've changed the code now to check if the assets entry is there via respond_to?.

That happens when Rails (5) is run in API mode
@pyromaniac
Copy link
Contributor

Perfect, thanks!

pyromaniac added a commit that referenced this pull request Dec 29, 2015
Guard against assets not being configured
@pyromaniac pyromaniac merged commit 9d00319 into toptal:master Dec 29, 2015
@clupprich
Copy link
Contributor Author

Awesome!

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