2011-05-13 95 views
0

我得到這個與db有關的錯誤。任何想法如何解決它?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 | 

回答

0

如果你正在跟蹤my article,那麼在這條線的控制器和您的模型錯過了屬性狀態:@articles = Article.where(:state => ['3', '4']).order('accepted desc')

編輯:只刪除在哪裏和使用Article.order('...')

+0

好猜,是你的文章!我試過這個,但它仍然不工作@articles = Article.order('accepted desc')。這是你的意思嗎? – ubique

+0

如果您的模型中有一個名爲accepted datetime的字段,那麼是的。否則,採取created_at。在這種情況下,您還需要更改atom_feed,在那裏使用接受的。 從頁面頂部的基本示例開始,並在其正在工作後自定義此示例可能會更容易... –

+0

對不起,你在那裏失去了我......? – ubique