RoR中的动态变量:已解决

问题描述 投票:1回答:1

通过RoR博客网站教程,但我不得不加入Disqus。它不喜欢我如何编写我的动态变量。所有这些仍然是新手。

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

var disqus_config = function () {
this.page.url = '<%= url_for([@post, {only_path: false}]) %>';
this.page.identifier = '<%= @post.id %>';
this.page.title = '<%= @post.title %>';
};

(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = 'https://myshortname.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>

更新:我注意到我的网址显示不正常。检查disqus javascript透露:

var disqus_config = function () {
this.page.url = '/posts/5'; //This should be a complete url
this.page.identifier = '5';
this.page.title = 'Article 5';
};

解决:我猜在Rails 5中url语法不同。

this.page.url = '<%= url_for(only_path: false) %>';
ruby-on-rails disqus
1个回答
0
投票
this.page.url = '<%= url_for(only_path: false) %>';
© www.soinside.com 2019 - 2024. All rights reserved.