Ruby On Rails 3 - Atom Feed 问题
我收到这个与数据库有关的错误。有什么想法如何解决吗?
/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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您正在关注我的文章,那么就是控制器中的这一行,并且您的模型缺少该属性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('...')