-
-
Notifications
You must be signed in to change notification settings - Fork 454
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
Clearance gem queries for users too many times #295
Comments
You will see one SQL I believe everything in Clearance and Rails is working as intended. Please provide logs if you're seeing something different. |
Hi Croaky, Thanks for your response. Unlike clearance, in devise gem we do not see the SQL SELECT into the users table.Please see the log below.
Thanks |
@vikrammishra333 I'm not sure how to avoid the SQL I don't recommend serving assets through your Rails app. Give asset_sync a try. |
It's querying for the user even when the user isn't necessary for the request. Some of the above log entries are assets in development, which certainly don't need the current user. I think I introduced this regression when moving logic into Rack middleware. This attempts to add the current user's remember token after each request: https://github.com/thoughtbot/clearance/blob/master/lib/clearance/rack_session.rb#L11 However, it doesn't check to see if the user has already been loaded before setting the cookie: https://github.com/thoughtbot/clearance/blob/master/lib/clearance/session.rb#L10 I think we could fix this by grabbing the remember token from |
@derekprior Agree. |
* reduces extra user lookups when adding cookie to headers * resolves issue #295
* reduces extra user lookups when adding cookie to headers * resolves issue #295
* reduces extra user lookups when adding cookie to headers * use the appropriate sign_out method in tests * resolves issue #295
Fixed in 9d2f949 |
I am using clearance gem for authentication purpose and it is working very much fine. But, the problem with it I found is, it slows down the application. By taking a closer look at this, I found that it fetches user for each and every assets(JavaScripts, CSS and images) requested for the page.
Can anyone suggest me what can be the work around for this?
Thanks in Advance
The text was updated successfully, but these errors were encountered: