vendredi 9 octobre 2015

Comparative conditional syntax between rails3 and 4

Under rails 3, the first condition below generates a desired array for the second query

@structures = Structure.where(['structureusers.user_id = ?', current_user]).joins(:users)
@structureuser = Structureuser.where(['structure_id IN (?) AND user_id = ?',@structures, @local_user]).first

However, under rails 4, this will result in a complaint that postgresql ERROR: subquery has too many columns.

Appending .to_a to the first statement processes the request and returns proper result. I realize this is how to operate under rails 4, but given the joins statement, I wonder whether I am not creating artifacts I should be aware of... or invoking improper syntax.

Aucun commentaire:

Enregistrer un commentaire