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

Adding omniauthable to to Spree::User #98

Closed
Draiken opened this issue May 23, 2017 · 4 comments
Closed

Adding omniauthable to to Spree::User #98

Draiken opened this issue May 23, 2017 · 4 comments

Comments

@Draiken
Copy link

Draiken commented May 23, 2017

Hi everyone, I've been having a few issues after adding omniauthable to the Spree::User class.

I used a module to prepend calls to devise and add any necessary extra methods, the problem happens on development when classes are reloaded.

I believe (haven't checked yet) that routes are reloaded before the core classes, so as soon as my routes file is read, it will setup the omniauthable routes, and load the Spree::User class but without my prepended module.
This causes every class reload on development require a full server restart.

I tried solving this by creating a ::User class, inherit from Spree::User and setting Spree.user_class = "::User" but apparently constantize thinks that means Spree::User :(

One thing that could help would be a hook to add extra parameters to the devise call, which would then correctly load omniauthable even before my prepended modules.

What do you guys think? Am I doing some glaring stupid mistake?

@mamhoff
Copy link
Contributor

mamhoff commented May 24, 2017

No, you're running into a difficult problem that, fortunately, has been solved in another extension. Check the solidus_social gem, maybe you're only one gem away from a solution to your issue.

@Draiken
Copy link
Author

Draiken commented May 29, 2017

Thanks! I'll check that out.

Meanwhile if anyone else encounters this, my solution is working: I added the module prepend to the routes file, forcing the Spree::User to be auto loaded and prepend my additional methods before the routes are evaluated. Development reloading is working perfectly now.

@Draiken Draiken closed this as completed May 29, 2017
@bbuchalter
Copy link
Contributor

I added the module prepend to the routes file, forcing the Spree::User to be auto loaded

I'm glad you got a working solution, but I'd wouldn't want to see the community adopting this strategy broadly. Adding my opinion for the record.

@Draiken
Copy link
Author

Draiken commented May 30, 2017

Which is why I opened this issue in the first place :)
If the devise modules that Spree::User sets were configurable, simply adding :omniauthable to that would suffice for the route generation.

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