Ruby On Rails 3 - Atom Feed 问题

发布于 2024-11-07 05:06:00 字数 1311 浏览 0 评论 0原文

我收到这个与数据库有关的错误。有什么想法如何解决吗?

/app/views/articles/feed.atom.builder:

atom_feed :language => 'en-gb' do |feed|
  feed.title "My Blog"
  feed.updated @articles.first.accepted

  @articles.each do |article|
    feed.entry article, :published => article.accepted do | entry |
      entry.title article.title
      entry.summary article.teaser + '<br /><br />Read the full article: <a href="' + article_url(article) + '">' + article_url(article) + '</a><br /><br />', :type => 'html'

      entry.author do |author|
        author.name article.user.fullname
      end
    end
  end
end

错误:

/app/views/articles/feed.atom.builder where line #5 raised:

SQLite3::SQLException: no such column: articles.state: SELECT "articles".* FROM "articles" WHERE "articles"."state" IN ('3', '4') ORDER BY accepted desc LIMIT 1
Extracted source (around line #5):

    2: 
    3: atom_feed :language => 'en-gb' do |feed|
    4:   feed.title "My Blog"
    5:   feed.updated @articles.first.accepted
    6:               
    7:   @articles.each do |article|
    8:     feed.entry article, :published => article.accepted do | entry |

I am getting this error that has to do with the db. Any ideas how to solve it?

/app/views/articles/feed.atom.builder:

atom_feed :language => 'en-gb' do |feed|
  feed.title "My Blog"
  feed.updated @articles.first.accepted

  @articles.each do |article|
    feed.entry article, :published => article.accepted do | entry |
      entry.title article.title
      entry.summary article.teaser + '<br /><br />Read the full article: <a href="' + article_url(article) + '">' + article_url(article) + '</a><br /><br />', :type => 'html'

      entry.author do |author|
        author.name article.user.fullname
      end
    end
  end
end

The error:

/app/views/articles/feed.atom.builder where line #5 raised:

SQLite3::SQLException: no such column: articles.state: SELECT "articles".* FROM "articles" WHERE "articles"."state" IN ('3', '4') ORDER BY accepted desc LIMIT 1
Extracted source (around line #5):

    2: 
    3: atom_feed :language => 'en-gb' do |feed|
    4:   feed.title "My Blog"
    5:   feed.updated @articles.first.accepted
    6:               
    7:   @articles.each do |article|
    8:     feed.entry article, :published => article.accepted do | entry |

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

混浊又暗下来 2024-11-14 05:06:00

如果您正在关注我的文章,那么就是控制器中的这一行,并且您的模型缺少该属性state: @articles = Article.where(:state => ['3', '4']).order('accepted desc')

编辑:只需删除 where 并使用 Article.order ('...')

If you are following my article, then it is this line in the controller and your model misses the attribute state: @articles = Article.where(:state => ['3', '4']).order('accepted desc')

Edit: Just remove the where and use Article.order('...')

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文