【问题标题】:Rails 3: adding DISQUS gem for commentsRails 3:为评论添加 DISQUS gem
【发布时间】:2023-04-07 01:28:01
【问题描述】:

您好,我正在尝试让 DISCUS cmets 在 Rails 3 应用程序中工作。似乎没有很好的设置指南。

评论系统不会出现,我在视图中看到的只是这个:

<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>

我哪里出错了?谢谢

【问题讨论】:

  • 您是否重新启动了服务器?在呈现的 HTML 中,#disqus_thread 中出现了什么?
  • 是的,我尝试重新启动服务器 :( 在 html 中呈现的唯一内容是:
  • @Jesse 您是否有机会使用 DISQUS 开发 Rails 应用程序?或者有让这个工作的经验?
  • @trying_hal9000 是的,但不使用 gem...如果您可以将页面公开,我可以帮助诊断可能发生的 javascript 错误
  • 谢谢,我认为这可能与我在本地运行有关,当我可以在生产服务器上启动它时,我肯定会知道,再次感谢

标签: ruby-on-rails ruby-on-rails-3 comments disqus


【解决方案1】:

我认为您需要使用 raw 或 html_safe。

 = raw disqus_thread

 = disqus_thread.html_safe

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-16
    • 2014-03-11
    • 2015-12-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多