root_path转到 rss 提要而不是根页面 Rails 4



>routes.rb:

...    
root 'pages#home'
...

页面控制器

class PagesController < ApplicationController
  def home
  end
  def directions
  end
...

主页上的提要div:

<div>
<p><strong>Sunday's Scripture Readings:</strong></p>
<script src="http://feed2js.org//feed2js.php?src=http%3A%2F%2Flectionary.library.vanderbilt.edu%2Ffeeds%2Flectionary.xml&desc=1" type="text/javascript" > </script></p>
</div>

无论我使用"返回"还是"root_path",网址都是正确的,但内容不是主页,而是 rss 提要:

February 28, 2016: Third Sunday in Lent (Year C)
Isaiah 55:1-9 * Psalm 63:1-8 * 1 Corinthians 10:1-13 * Luke 13:1-9

我尝试添加一个#标签,以转到主页上的特定div,但这不起作用。现在,当我在显示提要的页面上时,我可以点击刷新,它将转到主页。但我不能指望我的用户知道这一点。有什么建议吗?我注意到涉及Wordpress和rss的类似情况,但没有答案。是JavaScript的东西吗?

_path帮助程序会生成相对 URL,因此您的所有 URL 都相对于 RSS 源。

若要生成绝对 URL,请使用_url帮助程序。

因此,例如,不使用root_path而是使用root_url

有关更多信息,请查看官方文档。

最新更新