rho*_*dee 28 javascript ruby-on-rails disqus
我想使用通用代码,并且在完成最基本的功能时遇到了困难.
我想创建一个测试的短名称和一个我的部署,我在Disqus管理面板中做了.
这是我的show动作中的disqus代码:
# 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>
Run Code Online (Sandbox Code Playgroud)
在我定义的模型中Post,我定义了我的短名称,如下所示:
DISQUS_SHORTNAME = if Rails.env.development?
"dev-shortname".freeze
else
"shortname".freeze
end
Run Code Online (Sandbox Code Playgroud)
我可以确认加载微调器正在运行,但就是这样.我错过了一些明显的东西吗 当我尝试only_path: false在我的url_for调用中包含第二个选项时,我得到一个异常,说明我已经提供了该方法的许多参数.否则我的disqus就会挂起.
You*_*who 16
你应该设置它使其工作:
var disqus_developer = 1; // this would set it to developer mode
Run Code Online (Sandbox Code Playgroud)
参考:http: //ray247.wordpress.com/2009/09/02/how-to-develop-with-disqus-on-localhost/
Raf*_*der 13
截至2013年9月,上述解决方案均无效.
为了使它工作,我不得不将localhost添加到此页面上的"可信域"列表中:
http:// [disqus_shortname] .disqus.com/admin/settings/advanced /
并使用下面的"通用代码"将其嵌入我的博文:
http:// [disqus_shortname] .disqus.com/admin/settings/universalcode /
它的工作原理!:)