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

Custom Authenication undefined spree_current_user method #2076

Closed
huoxito opened this Issue Oct 11, 2012 · 6 comments

Comments

Projects
None yet
3 participants
@huoxito
Member

huoxito commented Oct 11, 2012

I followed this guide http://ryanbigg.com/spree-guides/authentication.html to set custom authentication but I keep getting this error after a while when the server starts.

undefined local variable or method `spree_current_user' for #<#<Class:0xc25b870>:0xba5f7fc>

I created this example app to reproduce the issue https://github.com/huoxito/spree-custom-auth-example-app. The error appears immediately after any change is added to the User model. It looks like the app loses the spree_ helper methods. Sorry but I don't know how to say it better.

Actually you just start the server and then save the User model and that error breaks the app. Is that Custom Authentication guide already supposed to work fine?

@huoxito

This comment has been minimized.

Show comment
Hide comment
@huoxito

huoxito Oct 11, 2012

Member

It looks like the issue may be solved by including AuthenticationHelpers module directly into the app ApplicationController. I still would appreciate some feedback on why the guides setup didn't work on that example app.

Member

huoxito commented Oct 11, 2012

It looks like the issue may be solved by including AuthenticationHelpers module directly into the app ApplicationController. I still would appreciate some feedback on why the guides setup didn't work on that example app.

@radar

This comment has been minimized.

Show comment
Hide comment
@radar

radar Oct 11, 2012

Member

The guide actually does cover it... it says this at the bottom of the AuthenticationHelpers file:

ApplicationController.send :include, Spree::AuthenticationHelpers

This means that the helpers will be included into ApplicationController when that file is loaded, which it is inside config/initializers/spree.rb

Member

radar commented Oct 11, 2012

The guide actually does cover it... it says this at the bottom of the AuthenticationHelpers file:

ApplicationController.send :include, Spree::AuthenticationHelpers

This means that the helpers will be included into ApplicationController when that file is loaded, which it is inside config/initializers/spree.rb

@radar

This comment has been minimized.

Show comment
Hide comment
@radar

radar Oct 11, 2012

Member

Verified. Added a new comment line to the User model and this caused the code to break. Will investigate.

Member

radar commented Oct 11, 2012

Verified. Added a new comment line to the User model and this caused the code to break. Will investigate.

@radar

This comment has been minimized.

Show comment
Hide comment
@radar

radar Oct 11, 2012

Member

This issue is happening because Spree::AuthenticationHelpers is only required once and included into ApplicationController. When the User model is edited, all classes are reloaded and that removes the AuthenticationHelpers inclusion into ApplicationController, resulting in this error.

The commits added to master and 1-2-stable just then will fix this problem. Sorry that it happened.

Member

radar commented Oct 11, 2012

This issue is happening because Spree::AuthenticationHelpers is only required once and included into ApplicationController. When the User model is edited, all classes are reloaded and that removes the AuthenticationHelpers inclusion into ApplicationController, resulting in this error.

The commits added to master and 1-2-stable just then will fix this problem. Sorry that it happened.

@huoxito

This comment has been minimized.

Show comment
Hide comment
@huoxito

huoxito Oct 12, 2012

Member

thanks for the fast feedback @radar I appreciate it.

Including the AuthenticationHelpers module directly into ApplicationController also should fix that on existing Spree apps.

Member

huoxito commented Oct 12, 2012

thanks for the fast feedback @radar I appreciate it.

Including the AuthenticationHelpers module directly into ApplicationController also should fix that on existing Spree apps.

@trappist

This comment has been minimized.

Show comment
Hide comment
@trappist

trappist Oct 12, 2012

Contributor

Fix confirmed, thanks @radar

Contributor

trappist commented Oct 12, 2012

Fix confirmed, thanks @radar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment