를, 내가 upvotes에 따라 내림차순으로 정렬하는 것을 시도하고있다 이미지가)) 내 서버 로그를 찾고 있었어요 그리고 그것은 대신 (각 항목에 대해, 'find_with_reputation'쿼리를 내림차순으로, 하나 개의 쿼리로 모든 이미지를 당기는 모양 때문에 정렬 할 수 없습니다
image_ids = ActiveRecord::Base.connection.execute("SELECT target_id FROM rs_reputations WHERE target_type = 'Image' ORDER BY value DESC")
image_ids = image_ids.map { |item| item = item[0] }
@images = []
image_ids.each { |id| @images << Image.find(id) }
. 그것은 또한 '가치'를 쿼리하지 않습니다.
ReputationSystem::Reputation Load (0.2ms) SELECT "rs_reputations".* FROM "rs_reputations" WHERE "rs_reputations"."reputation_name" = 'votes' AND "rs_reputations"."target_id" = 14 AND "rs_reputations"."target_type" = 'Image' LIMIT 1
ReputationSystem::Reputation Load (0.3ms) SELECT "rs_reputations".* FROM "rs_reputations" WHERE "rs_reputations"."reputation_name" = 'votes' AND "rs_reputations"."target_id" = 15 AND "rs_reputations"."target_type" = 'Image' LIMIT 1
ReputationSystem::Reputation Load (0.3ms) SELECT "rs_reputations".* FROM "rs_reputations" WHERE "rs_reputations"."reputation_name" = 'votes' AND "rs_reputations"."target_id" = 17 AND "rs_reputations"."target_type" = 'Image' LIMIT 1
솔루션 : 하나에 쿼리를 응축, 또는 값을 기준으로 정렬 한 후 배열에 각 쿼리 결과를 밀어 어느.
편집 :이 문제는 PostgreSQL에서 MySQL로는 잘 작동하지만 PostgreSQL에서는 그렇지 않습니다. 내가 처리하는 방법을 잘 모르는 PG :: RESULT 객체를 받는다.
로그를 제공하지 않으면 도움을 줄 수 없습니다. 여기에 가서 레일 애플리케이션을 디버깅하는 방법을 읽어보십시오. http://nofail.de/2013/10/debugging-rails-applications-in-development/ – phoet
테스트에 따라 작동해야합니다. 지금 당장은 파고 들지 않지만 검색어는 무엇인가요? – NARKOZ
Rails 서버에서 색인 페이지를로드 할 때 다음과 같이 알려줍니다. Rendered /Users/USername/.rvm/gems/ruby-1.9.3-p392/gems/actionpack-4.0.0/lib/action_dispatch/middleware/templates/rescues/routing_error. 자원 : 글꼴 멤버 {얻을 : 같은} 않습니다 구출 내 ERB는/레이아웃 – piratebroadcast