if you want to use something like #{...} in an association condition, :order, etc, you need to use singel quotes around the sql fragment. the reason being is that the string is being interpreted when the class is loaded and it doesn't know what topic_id is. #{} is not interpreted inside single quotes.
Related topics
| Topic | Replies | Views | Activity | |
|---|---|---|---|---|
| Incorporating runtime parameters in has_many :conditions | 1 | 153 | November 28, 2006 | |
| Associations interpolate_sql() context? | 3 | 149 | March 23, 2008 | |
| missing interpolate_sql in JoinAssociation | 5 | 166 | October 11, 2006 | |
| Edge rails: associations in sanitize_sql_hash_for_conditions hack/feature | 3 | 88 | October 17, 2007 | |
| Ticket #5971 - Patch to fix sanitize_sql for associations. | 0 | 136 | August 31, 2006 |