When working with nested models, activerecord can use prepared statements like the following :
$> Cursus.find(1).projects.to_sql
=> "SELECT \"projects\".* FROM \"projects\" INNER JOIN \"cursus_projects\" ON \"projects\".\"id\" = \"cursus_projects\".\"project_id\" WHERE \"cursus_projects\".\"cursus_id\" = $1" #(note the $1)
When coupling with all_json, it creates an PG::ProtocolViolation: ERROR: bind message supplies 0 parameters, but prepared statement "" requires 1 error.
Replace to_sql by to_sql_with_binding_params fixes the problem.
When working with nested models, activerecord can use prepared statements like the following :
When coupling with all_json, it creates an
PG::ProtocolViolation: ERROR: bind message supplies 0 parameters, but prepared statement "" requires 1
error.Replace
to_sql
byto_sql_with_binding_params
fixes the problem.