As a relative newbie to Rails, I'm not sure how to approach this. I am looking to add a basic "Login with Facebook" fe开发者_如何学JAVAature to a practice site I am developing. I am stuck on two fronts:
Most Rails plugins dealing with Facebook seem out of date or poorly documented. I've encountered Facebooker (seems to have died off from what I see) and Mini_FB (more recent, but very little documentation). I tried to install Mini_FB, but I am still very unfamiliar about working with Gems. I ran
gem install mini_fb
, thenbundle install
, and finally addedgem 'mini_fb'
to my Gemfile, but my server complains of ano such file to load
error. Are there any other steps necessary to allow your app to use a gem?I am confused by how the "Login with Facebook" feature works from an overall birds-eye view. I understand that my App ID is passed into the login feature, and I ultimately get an access token (after resubmitting with my App Secret Key and an authorization code). But how does this integrate with some kind of user system on a Rails site? Since this access code doesn't last forever, do I need to renew it periodically? Is that done by simply waiting to catch an access token error from a Graph request and redoing the entire authorization procedure?
Have you tried OmniAuth?
It supports a whole host of external providers, including facebook.
There are also a number of railscasts on it's use.
The correct order of installing a gem on your application would be first adding it to your Gemfile.rb, then running bundle install
on your console. That being said, OmniAuth is probably the best path for you
精彩评论