加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – Rails 3:添加DISQUS gem以供评论

发布时间:2020-12-17 02:11:17 所属栏目:百科 来源:网络整理
导读:嗨,我正在尝试在Rails 3应用程序中使用DISCUS评论.这似乎不是一个很好的指南来设置它. 评论系统不会显示,我在视图中看到的是: script type="text/javascript"var disqus_developer = 1;/scriptdiv id="disqus_thread"/divscript type="text/javascript" src
嗨,我正在尝试在Rails 3应用程序中使用DISCUS评论.这似乎不是一个很好的指南来设置它.

评论系统不会显示,我在视图中看到的是:

<script type="text/javascript">var disqus_developer = 1;</script><div id="disqus_thread"></div>
<script type="text/javascript" src="http://disqus.com/forums/gppublic/embed.js"></script>
<noscript><a href="http://gppublic.disqus.com/?url=ref">View the discussion thread</a></noscript>

这是我设置它的步骤:

1)gem install disqus

2)将配置块放在application.rb中并??添加您的特定帐户名称

config.after_initialize do
    Disqus::defaults[:account] = "youraccountname"
    # so that the comments will load up in development environment
    Disqus::defaults[:developer] = true
    Disqus::defaults[:container_id] = "disqus_thread"
    Disqus::defaults[:show_powered_by] = false
    end

3)然后放在我的节目视图中

<div id ="disqus_thread">
<%= disqus_thread %>
</div>

我哪里错了?谢谢

解决方法

我认为你需要使用raw或html_safe.

= raw disqus_thread

要么

= disqus_thread.html_safe

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读