6

I've set up a Rails 3.2 application with Devise. I was wondering how I can allow users to comment using Facebook. Can I use facebook connect along with Devise? If I can, is it ok to have 2 methods of authentication on my site?

I've read some tutorials on setting up OAuth with Devise to allow facebook connect, but it's not all that clear to me. Does anyone know a good step-by-step tutorial on how to integrate facebook comments with Devise already set up? Thanks a lot!

gerky
  • 6,267
  • 11
  • 55
  • 82

1 Answers1

11

You don't need to setup Facebook Connect for comments.

You have to first create a Facebook app, then generate the comments plugin. After, put the Javascript code in your application.html.erb after the body tag (my suggestion is to make a partial). In the end, drop the div with the fb-comments class where you want the comments box to appear.

Alex Palcuie
  • 4,434
  • 3
  • 22
  • 27
  • Cool, that saved me a lot of time. I have a question though, when I generate the comments plugin, there's a field 'URL to comment on'. Should I only put there the root domain? Or do I have to change the data-href attribute to the url of each page? – gerky Aug 21 '12 at 15:01
  • Like set the data-href of the fb-comments div to "#{request.protocol}#{request.host_with_port}#{request.fullpath}"? – gerky Aug 21 '12 at 15:13
  • 1
    It depends on your needs: if you want a single comment "topic" over all your website, just include the protocol and host If you want different comment "topics", like for each article on your website use `request.url` to generate – Alex Palcuie Aug 21 '12 at 19:57
  • Thanks, though I think request.url is now deprecated based on http://stackoverflow.com/questions/2165665/how-to-get-current-url-in-rails – gerky Aug 22 '12 at 04:37
  • How would you save these comments with ActiveRecord? – Ctpelnar1988 Aug 23 '16 at 14:53