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

Eager Loading #683

Closed
jacaetevha opened this issue Mar 14, 2015 · 2 comments
Closed

Eager Loading #683

jacaetevha opened this issue Mar 14, 2015 · 2 comments

Comments

@jacaetevha
Copy link

Would it be acceptable to add options for doing eager loading when logging in a user?

E.g.

def find_by_credentials(*credentials)
  # ...
  arel = @klass.where(relation)
  arel = arel.includes(@eager_loading_options) if @eager_loading_options.present?
  arel.first
end
config.user_config do |user|
  user.eager_loading = {things: {other_things: [:then, :that, :stuff]}}
end
@arnvald
Copy link
Collaborator

arnvald commented Mar 16, 2015

Hi @jacaetevha,

thanks for suggestion. I don't think we should add this, though. The main reason is that it goes beyond the scope of Sorcery - it has nothing to do with authentication. Another reason is that there are a few places where user model is loaded - not only find_by_credentials but also load_from_provider, find_by_token etc, so adding this would add a lot of complexity.

@arnvald arnvald closed this as completed Mar 16, 2015
@ivanreese
Copy link

I'd also like to be able to use includes to do eager loading with the current_user, to load (for instance) associated permissions used for authorization.

The pull request for adding a scope_for_authentication seems like it'd support this use case: #727

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