问题描述
我想使用通用代码,并且在完成最基本的功能时遇到了困难。
I would like to use the universal code and have ran into difficulties getting the most basic functionality done.
我想为测试创建一个短名称,还有一个用于我的部署,我在Disqus管理界面中做了一次。
I would like to create a shortname for test and one for my deployment, which I did from the Disqus admin panel.
这是我的show动作中的disqus代码:
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>
在我的模型中,我定义 Post
,I像这样定义我的短名称:
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
我可以确认加载微调器正在运行,但就是这样。我错过了一些明显的东西吗当我尝试在我的url_for调用中包含 only_path:false
作为第二个选项时,我得到一个异常,说明我已经提供了该方法的许多参数。否则我的disqus就会挂起。
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.
推荐答案
你应该设置它以使它工作:
you should set this to make it work:
var disqus_developer = 1; // this would set it to developer mode
参考:
这篇关于Disqus注释无法加载localhost?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!