2011-05-13 6 views
0

db와 관련하여이 오류가 발생합니다. 어떤 아이디어가 그것을 해결하는 방법?Ruby On Rails 3 - Atom 피드 문제

/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

모델에 datetime 유형의 허용 필드가 있으면 yes입니다. 그렇지 않으면 created_at을 취하십시오. 이 경우 atom_feed도 변경해야하며 허용 된 값이 사용됩니다. 페이지 상단의 기본 예제로 시작하여 작동 후이 예제를 쉽게 사용자 정의 할 수 있습니다 ... –

+0

죄송합니다. – ubique