2011-05-26 53 views
0

我得到這個錯誤,當我嘗試設置分頁在飼料中的元素:錯誤與分頁

ActiveRecord::StatementInvalid in Videos#feed_display 

Showing /rubyprograms/dreamstill/app/views/videos/feed_display.html.erb where line #6 raised: 

SQLite3::SQLException: only a single result allowed for a SELECT that is part of an expression: SELECT "timeline_events".* FROM "timeline_events" WHERE (SELECT timeline_events.* FROM timeline_events 
             WHERE ((actor_type = 'User' AND actor_id IN (SELECT followed_id FROM relationships WHERE follower_id = 2)) AND ((secondary_subject_type = 'Video' AND subject_type <> 'Profile' AND secondary_subject_id NOT IN (SELECT id FROM videos WHERE user_id = 2)) OR (secondary_subject_type = 'User' AND secondary_subject_id <> 2) OR (secondary_subject_type = 'nil') OR (subject_type = 'Profile' AND secondary_subject_id NOT IN (SELECT id FROM videos WHERE user_id = 2) AND subject_id NOT IN (SELECT id FROM profiles WHERE user_id = 2)))) 
             ORDER BY timeline_events.created_at DESC) LIMIT 10 OFFSET 0 

這是什麼意思?如何解決呢?

+0

你的子查詢返回多個列 – 2011-05-26 05:01:10

+0

你是什麼意思?我該如何解決這個問題? – 2011-05-26 05:05:05

回答

0

其中一個子查詢返回多個結果。這可以通過在子查詢中添加Distinct或Limit 1來解決。我會使用Firefox的插件「Sqlite Manager」來測試這個查詢。

+0

是的,在任何地方,我在WHERE子句中有一個SELECT返回多個記錄,因爲我正在測試以查看該範圍內是否有內容。如果我將範圍限制爲只有一條記錄,那麼SQL代碼將無法按需要工作。 – 2011-05-26 16:53:38