PostgreSQL
 sql >> Database >  >> RDS >> PostgreSQL

finder_sql non analizza la stringa con Rails

Penso che quello che stai effettivamente cercando sia questo:

has_many :posts, :finder_sql =>
    proc {"SELECT p.* from posts p join topics t on p.topic_id = t.id where t.id=#{id}"}

A partire da Rails 3.1 devi usare un proc invece di una stringa per usare campi come #{id} .

Consulta il problema qui:https://github.com/rails/rails/issues/3920