Tuesday, 15 March 2011

PostgreSQL syntax error Rails 4 -


I have a railway 4 app that he has.

No error was found in the development using MySQL

I get the following in production on Herocon:

  March 16 09:40: 22 SquareShipd App / Web Get 1: 87.83.45.218 for "/" 2015-03-16 16:40:22 +0000 March 16 09:40:22 SquareShepped App / Web.1: Processed by PageSender # Index HTML As 16 March 09:40:23 SquareShiped App / Web 1: PG :: Syntax Error: Error: Syntax Error "or" Near ")" Mar 16 09:40:23 Squarespread App / Web.1: Line 1: SELECT COUNT (*) "COURSE" WHERE "COURSE" "Id" IN () Mar 16 09:40:23 SquareSheeped app / web.1: ^ Mar 16 09:40:23 SquareSheeped app / web.1: "Choose" from "Course" Where "Course" "ID" IN () March 16: 40:23 SquareShipd app / Web 1: Landed / in-page rendered page / index.html.erb (69.8 ms) Mar 16 09:40:23 SquareShipd app / Web 1 : ActionWise :: Template :: Error (PG :: Syntax Error: Error: Syntax Error Error or Pass) "March 16, 23 Squarespad App / Web.1: Line 1:" Course "from Select COUNT (*) Where" Sea SquareShiped App / Web 1: ^  

I thought this could be because my code is asking for it A value in the empty array so I have a couple I statement, so it does not appear that the array was empty. This is not working

  def index = curriculum = course.limit (7) .dir (created_as: desc) @reviews = review.limit (7) .order (created_at :: Desc) if user_signed_in? Find out the peer recommended courses, @viewer = users. ("What is the situation like?", Present_up.). Where ('id & lt; & gt;?, Current_user.id) @peer_recommended_courses = [] @ peers.each do | Peer | @peer_recommended_courses & lt; & Lt; Peer.reviews.where (recommended: true) .pluck (: course_id) end if @ peer_recommended_courses.empty? @peer_recommendations = [] Other @peer_recommendations = course. Here (id: @peer_recommended_courses) End # fund company recommended @ colleagues = user.where ("like company?", Current_user.company). Where ('id & lt; & gt; ?, Current_user.id) @colleague_recommended_courses = [] @ colleague. Colleague @College_Raymond Series & lt; & Lt; Peer.reviews.where (recommended: true) .pluck (: course_id) end if @ colleague_recommended_courses.empty? @colleague_recommendations = [] and @colleague_recommendations = course.here (id: @collage_armeded seat) end and end  

If someone can explain why this error is happening then I would be grateful .

PS apologizes for terrible coding, I am a lot more a Noble and most of these probably will be in my course model. I am working on it. Just want to ship this update

The query is still running because @peer_recommended_courses < / Code> is not an empty array.

  @peer_recommended_courses = [] @ peers.each Do it. Colleague @peer_recommended_courses & lt; & Lt; Peer.reviews.where (recommended: true) .pluck (: course_id) expiration  

If no peer review is made where recommended, then @peer_recommended_courses now actually [[]] is not just [] . Flatten the array so that the Arel query is handled properly (or leveling the array before empty? ):

  @peer_recommendations = course. : @peer_recommended_courses). Flatten)  

No comments:

Post a Comment