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

facebook login issue on heroku #74

Closed
ghost opened this issue Oct 3, 2011 · 6 comments
Closed

facebook login issue on heroku #74

ghost opened this issue Oct 3, 2011 · 6 comments

Comments

@ghost
Copy link

ghost commented Oct 3, 2011

I'm sorry if this is trivial, but I just can't solve this.

Facebook login works fine on local server, but not on Heroku:

2011-10-03T03:50:21+00:00 app[web.1]: Started GET "/oauth/callback?provider=facebook&code=AQAJ-kjae6XnC-4R82G3DlaYseLxKFK09t9EN5Cwk-MuoctkE1iiY-tKVGM1n9YkUjhyjmhZptdOkxyytFWgFHB2RlihH1S3FdsysmKLlw7UztqczyLys_plQIRdF7YzRUi0dGqynn9j9rkqHNK7KWqswT62usruyumS0m0d4LRCauCnPQ-SPtrNrFRdeWe0Aww" for 154.5.97.249 at 2011-10-03 03:50:21 +0000
2011-10-03T03:50:21+00:00 app[web.1]: Processing by OauthsController#callback as HTML
2011-10-03T03:50:21+00:00 app[web.1]: Parameters: {"provider"=>"facebook", "code"=>"AQAJ-kjae6XnC-4R82G3DlaYseLxKFK09t9EN5Cwk-MuoctkE1iiY-tKVGM1n9YkUjhyjmhZptdOkxyytFWgFHB2RlihH1S3FdsysmKLlw7UztqczyLys_plQIRdF7YzRUi0dGqynn9j9rkqHNK7KWqswT62usruyumS0m0d4LRCauCnPQ-SPtrNrFRdeWe0Aww"}
2011-10-03T03:50:21+00:00 app[web.1]: Completed 500 Internal Server Error in 841ms

0-03T03:50:21+00:00 app[web.1]:
2011-10-03T03:50:21+00:00 app[web.1]: NoMethodError (undefined method 'load_from_provider' for #<Class:0x00000003fd4190>):
2011-10-03T03:50:21+00:00 app[web.1]: app/controllers/oauths_controller.rb:12:in 'callback'
2011-10-03T03:50:21+00:00 app[web.1]:
2011-10-03T03:50:21+00:00 app[web.1]:
2011-10-03T03:50:21+00:00 app[web.1]: cache: [GET /oauth/callback?provider=facebook&code=AQAJ-kjae6XnC-4R82G3DlaYseLxKFK09t9EN5Cwk-MuoctkE1iiY-tKVGM1n9YkUjhyjmhZptdOkxyytFWgFHB2RlihH1S3FdsysmKLlw7UztqczyLys_plQIRdF7YzRUi0dGqynn9j9rkqHNK7KWqswT62usruyumS0m0d4LRCauCnPQ-SPtr

I have copied your sample external tutorial for the code in oauths_controller.rb
setup: rails 3.1.0, sorcery 0.6.1

@adamkangas
Copy link

I had a very similar issue. Thought it was Heroku's fault, but ran locally in production mode and experienced it too.

It seems to have to do with the order that initializers are loaded, and the fact that classes are cached in production mode.

I haven't bothered checking exactly which of my initializers was the problem, but I have a hunch that the culprit is that my RailsAdmin conf in rails_admin.rb and loading the User class before sorcery.rb was run. I changed the filename to 00_sorcery.rb and everything is happy once again.

If other people can confirm, this may be worthy of a README or Wiki item.

#136
http://stackoverflow.com/questions/4779773/how-do-i-change-the-load-order-of-initializers-in-rails-3

@mlainez
Copy link
Collaborator

mlainez commented Nov 7, 2011

I just tested with a simple app on heroku with and without rails_admin and did have any issue. Could somebody confirm that this is still an issue?

@adamkangas
Copy link

Could very well be related to ANY gem which has an opportunity to mess around with the User model before Sorcery has a chance to properly initialize. Really not sure what gems the original reporter is working with.

In your case, does your User class actually appear inside of your RailsAdmin? If not, what happens if you explicitly try to configure the User model?

RailsAdmin.config do |config|
  config.model User do
  end
end

The point here is that the line 2011-10-03T03:50:21+00:00 app[web.1]: NoMethodError (undefined method 'load_from_provider' for #Class:0x00000003fd4190>): corresponds to load_from_provider being called on our User (or whatever) class before Sorcery has had a chance to actually ADD it to the class.

I wrote a bit of a followup here #147

@mlainez
Copy link
Collaborator

mlainez commented Nov 8, 2011

I mean, if it is not an issue related to facebook nor heroku, is it still relevant to keep it open? Especially now that you've clearly explained the situation in a separate issue.

@adamkangas
Copy link

Yeah, this should be safe to close.

@mlainez mlainez closed this as completed Nov 8, 2011
@mlainez
Copy link
Collaborator

mlainez commented Nov 8, 2011

Closed because unrelated to facebook or heroku. For those who have a similar problem refer to @adamkangas follow up #147

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

No branches or pull requests

2 participants