Created
August 12, 2014 03:13
-
-
Save zhangxu/b8428f31267f6c5c6907 to your computer and use it in GitHub Desktop.
ActiveRecord Raw SQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@results = [] | |
ActiveRecord::Base.connection.select_all( | |
ActiveRecord::Base.send(:sanitize_sql_array, | |
["select * from events where area_type = ? and area_id = ?", 'parcel', '1']) | |
).each do |record| | |
# instead of an array of hashes, you could put in a custom object with attributes | |
@results << {id: record["id"], category: record["category"]} | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment