views:

51

answers:

1

I am doing some plain SQLs in my rails model (for purists this is just for complex SQLs :)

Since I am not using find*/condition methods, is there a helper method that I can use straight to do that?

+2  A: 

The quote method on the connection object escapes strings. When building up queries, use sanitize_sql_for_conditions to convert ActiveRecord conditions hashes or arrays to SQL WHERE clauses.

The methods in ActiveRecord::ConnectionAdapters::DatabaseStatements are handy for direct queries, in particular the ones starting with select_.

Jason Weathered
yes in my model I am doing connection.select_all(sql). But I cant find the "quote" method on connection object in rdoc for escaping my input params for where conditions.
Okay i got it, thanks!