Skip to main content

Facebook Profile Image & Data using Devise in Rails

Gems / Libraries • Asked by Omar Khedr

I'm just starting to learn Rails so please forgive the dumb question. In my web app, I was able to set up devise successfully and then link it Facebook using Omni-auth gem. However, two things occur.

1) A person who signs in using Facebook doesn't register as logged in - the Navbar still shows "Login"

2) I added an avatar so users can show their profile picture. While a regular devise user can added it without a problem. Someone who logs in with Facebook doesn't have their image displayed.

Any help that you guys can give me would be so amazing, I feel like the issue might be in my user.rb file. I have listed below all my relevant code and my github url. Thank you again :)

Github-url: https://github.com/OmarZV/TY2


I'm not quite sure on #1, but as for #2, you've got paperclip which wants an actual file. Facebook's API is only going to return you the url of the file, so you've got to tell Paperclip that you want it to download the file from the URL.

    user.image = URI.parse(auth.info.image)

You'll want to modify your User method like this in order to actually assign a URI object to the image which Paperclip will know to download.

http://stackoverflow.com/questions/4049709/save-image-from-url-by-paperclip


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 27,623+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.