How to add Disqus

comments to Ruby On Rails

Hash tags: Disqus| Ruby on Rails|

The Disqus for WordPress plugin lets site owners and developers easily add Disqus to their sites, replacing the default WordPress comment system. Disqus installs in minutes and automatically imports your existing comments.

In other words Easy way to add comments to any small public project. I was planning to built my own comment section with DB and relationships but then I found this cool add-on - disqus

1) Create new account and login;
2) Click "I want to install I want to comment on sites"
Screen Shot 2019-06-17 at 10.06.14 PM.png 371 KB
3) Create a new site. Provide all requested information on the form.
4) Select a platform. Click on "I don't see my platform listed, install manually with "
Screen Shot 2019-06-17 at 10.09.58 PM.png 48.7 KB
5) On the next page there will be 2 video tutorials which is useful to watch. Copy the script.
<div id="disqus_thread"></div>
<script>

/**
*  RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
*  LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables*/
/*
var disqus_config = function () {
this.page.url = PAGE_URL;  // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};
*/
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = 'https://yourhost.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
6) Now it's up to you how to implement it in rails ether it will be a partial or just directly to html.
7) Change 2 config variables: 

this.page.url = PAGE_URL;
this.page.identifier = PAGE_IDENTIFIER;
you will need these simply for telling disqus api how to distinguish one comment from another. It will group comments by url and uniq id. For example if you have a blog page the variables will be like following:

this.page.url = "http://skrdev.com/blogs/<%= @blog.id %>";
this.page.identifier = "blog<%= @blog.id %>";
Imbedded ruby will keep it dynamic.
8) rails s
9) Enjoy

Links:
https://disqus.com/
https://www.youtube.com/channel/UC8Ufy3krZ3p6-uMXMeQYZXA 

PROJECTS


MORE BLOGS