is it possible to specify parameters for :joins similar way as for :conditions?
here is an example (sql code is irrelevant)
named_scope :threads, {
:joins => [" LEFT JOIN groups_messages gm ON messages.id=gm.message_id AND gm.group_id IN (?) ",@group_ids_array],
:conditions => ["creator_id=? AND messages.id IN (?)", current_user_id, @message_ids_array]
}
in this example parameters for :conditions would get inserted properly, but for :joins i would get an error
Association named ' LEFT JOIN groups_messages gm ON messages.id=gm.message_id and gm.group_id IN (?) ' was not found; perhaps you misspelled it?
what function substitutes parameters for :conditions?
You can use the ActiveRecord::sanitize_sql_array method.
ActiveRecord::sanitize_sql_array ['gm.group_id IN (?)', @group_ids_array]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With