many cases, we use model to use find_by_sql like ModelName.find_by_sql, but now how we can find_by_sql without mode?
ActiveRecord::Base.connection.execute 'select * from users'To return array of hashes, you can use it :
ActiveRecord::Base.connection.select_all.
1 Response to "How to use find_by_sql without Model"
This will work, but won't allow you to populate variables with "?" like find_by_sql does. I found this link told me how to fix that:
http://blog.rlucas.net/bugfix/svn_set_default_properties_like_keywords/
Post a Comment