Feedjira 不添加内容和作者
Feedjira not adding content and author
我刚刚又开始 Rails,最近关注了 Sitepoint guide to building an RSS Feed app。我逐字按照说明进行操作,但收到错误 undefined method 'html_safe' for nil:NilClass
。我查看了数据库,似乎 Feedjira 没有将 content
或 author
属性解析到数据库中。
快速 google 后,我在 Github 页面 #178 and #176 dated back from August 13, but given the significant issue this causes I'm surprised there's not on it. It may be an error in my code which can be found here 上发现了以下问题,但我已经检查过,但我认为不是。
有人知道我做错了什么吗?我已经按照 Issue #176 中的建议更改了 feedjira 文档中的 self.feed_classes,但它仍然没有找到任何东西。
好的。我找到了问题所在。我克隆了你的项目并启动了。显然您的 show.html.erb
供稿页面与文章中的页面不同,这就是您无法访问条目的原因:
如果您想查看条目,请先创建带有名称和描述的新提要,例如为每个提要添加这些 link:
http://feedjira.com/blog/feed.xml
当您完成添加提要后,从您的终端在根应用程序中,运行 cd lib/task
最后 运行:bundle exec rake sync:feeds
正如文章中提到的:
The rake task loops through all the Feeds stored in the database and
fetches the latest content for each one. From that, loop through the
new Entries, creating or updating it in the database. We are updating
every time to keep up with any change in the source content.
现在,如果您转至下面的 link,或者通过 link 显示第一个供稿:
http://localhost:3000/feeds/1/entries
您应该能够看到供稿 ID 1 的所有条目。
希望对您有所帮助。
RSS 和 Atom Feeds 不提供内容属性。 'content' 作为 'summary' 属性提供。所以改变
local_entry.update_attributes(content: entry.content, author: entry.author, url: entry.url, published: entry.published)
至
local_entry.update_attributes(content: entry.summary, author: entry.author, url: entry.url, published: entry.published)
然而,NewsFeeds 是非常善变的东西。所以你不应该依赖单一属性的存在。
看看你的show.html.erb
<%= @entry.content.html_safe %>
例如,您可以使用安全导航运算符
<%= @entry&.content&.html_safe %>
或者通知用户,没有内容存在
<% unless @entry.content.nil? %>
<%= @entry.content.html_safe %>
<% end %>
我刚刚又开始 Rails,最近关注了 Sitepoint guide to building an RSS Feed app。我逐字按照说明进行操作,但收到错误 undefined method 'html_safe' for nil:NilClass
。我查看了数据库,似乎 Feedjira 没有将 content
或 author
属性解析到数据库中。
快速 google 后,我在 Github 页面 #178 and #176 dated back from August 13, but given the significant issue this causes I'm surprised there's not on it. It may be an error in my code which can be found here 上发现了以下问题,但我已经检查过,但我认为不是。
有人知道我做错了什么吗?我已经按照 Issue #176 中的建议更改了 feedjira 文档中的 self.feed_classes,但它仍然没有找到任何东西。
好的。我找到了问题所在。我克隆了你的项目并启动了。显然您的 show.html.erb
供稿页面与文章中的页面不同,这就是您无法访问条目的原因:
如果您想查看条目,请先创建带有名称和描述的新提要,例如为每个提要添加这些 link:
http://feedjira.com/blog/feed.xml
当您完成添加提要后,从您的终端在根应用程序中,运行 cd lib/task
最后 运行:bundle exec rake sync:feeds
正如文章中提到的:
The rake task loops through all the Feeds stored in the database and fetches the latest content for each one. From that, loop through the new Entries, creating or updating it in the database. We are updating every time to keep up with any change in the source content.
现在,如果您转至下面的 link,或者通过 link 显示第一个供稿:
http://localhost:3000/feeds/1/entries
您应该能够看到供稿 ID 1 的所有条目。
希望对您有所帮助。
RSS 和 Atom Feeds 不提供内容属性。 'content' 作为 'summary' 属性提供。所以改变
local_entry.update_attributes(content: entry.content, author: entry.author, url: entry.url, published: entry.published)
至
local_entry.update_attributes(content: entry.summary, author: entry.author, url: entry.url, published: entry.published)
然而,NewsFeeds 是非常善变的东西。所以你不应该依赖单一属性的存在。
看看你的show.html.erb
<%= @entry.content.html_safe %>
例如,您可以使用安全导航运算符
<%= @entry&.content&.html_safe %>
或者通知用户,没有内容存在
<% unless @entry.content.nil? %>
<%= @entry.content.html_safe %>
<% end %>