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

Concern causes app to connect to database when precompiling assets. #327

Closed
ArneZsng opened this issue Aug 5, 2015 · 2 comments
Closed

Comments

@ArneZsng
Copy link
Contributor

ArneZsng commented Aug 5, 2015

The user concern:

include DeviseTokenAuth::Concerns::User

causes the the app to try to connect to the database on initialize. This causes a problem when precompiling assets in a Dockerfile with

bundle exec rake assets:precompile

as no database is available during building the Docker image.

I have found a workaround for now by setting an environment variable dynamically:

  if ENV['INITIALIZE'] == "true"
    include DeviseTokenAuth::Concerns::User
  end
@booleanbetrayal
Copy link
Collaborator

Hmmm ... I'm open to suggestions on a generalized approach at resolving this in a way that is backwards compatible and remains performant for existing users. Maybe something along the lines of checking ActiveRecord::Base.connection and rescueing gracefully upon failure?

@luyzdeleon
Copy link

Has there been any news on this?

cbliard added a commit to hiptest/devise_token_auth that referenced this issue Jan 19, 2017
Fixes lynndylanhurley#327

When precompiling assets while building a docker image, the database is not
available and the DeviseTokenAuth::Concerns::User concern tries to load
user table information from database and fails. It now checks if the
database connection is established before gathering information about user
table.
cbliard added a commit to hiptest/devise_token_auth that referenced this issue Jan 20, 2017
Fixes lynndylanhurley#327

When precompiling assets while building a docker image, the database is not
available and the DeviseTokenAuth::Concerns::User concern tries to load
user table information from database and fails. It now checks if the
database connection is available before gathering information about user
table.
bartes pushed a commit to bartes/devise_token_auth that referenced this issue Apr 13, 2017
Fixes lynndylanhurley#327

When precompiling assets while building a docker image, the database is not
available and the DeviseTokenAuth::Concerns::User concern tries to load
user table information from database and fails. It now checks if the
database connection is available before gathering information about user
table.
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

No branches or pull requests

3 participants