Disqus comments fails to load on localhost?

rhodee picture rhodee · Feb 28, 2012 · Viewed 16.1k times · Source

I would like to use the universal code and have ran into difficulties getting the most basic functionality done.

I would like to create a shortname for test and one for my deployment, which I did from the Disqus admin panel.

Here is the disqus code in my show action:

# inside show.html.erb
<%= render raw 'comments' %>

# partial "comments"

  <div id="disqus_thread"></div>
    <script type="text/javascript">
      var disqus_shortname = '<%= Post::DISQUS_SHORTNAME %>';
      var disqus_identifier = '<%= @post.id %>';
      var disqus_url = '<%= url_for([:blog, @topic, @post])%>';
        (function() {
            var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
            dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
            (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
        })();
    </script>
    <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
    <a href="http://disqus.com" class="dsq-brlink">blog comments powered by <span class="logo-disqus">Disqus</span></a>

In my model I define Post, I define my short name like so:

  DISQUS_SHORTNAME = if Rails.env.development? 
                        "dev-shortname".freeze
                     else
                        "shortname".freeze
                     end

I can confirm the loading spinner is functioning but that is it. Am I missing something obvious? When I try to include only_path: false as a second option in my url_for call, I get an exception stating I have supplied to many arguments to the method. Otherwise my disqus just hangs.

Answer

You knows who picture You knows who · Feb 28, 2012

you should set this to make it work:

var disqus_developer = 1; // this would set it to developer mode

Reference: http://ray247.wordpress.com/2009/09/02/how-to-develop-with-disqus-on-localhost/