How to integrate facebook comments in Rails application?
Asked Answered
B

1

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!

Burgas answered 21/8, 2012 at 6:8 Comment(0)
G
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.

Gluttonous answered 21/8, 2012 at 10:23 Comment(5)
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?Burgas
Like set the data-href of the fb-comments div to "#{request.protocol}#{request.host_with_port}#{request.fullpath}"?Burgas
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 generateGluttonous
Thanks, though I think request.url is now deprecated based on #2166165Burgas
How would you save these comments with ActiveRecord?Mimesis

© 2022 - 2024 — McMap. All rights reserved.