简体   繁体   中英

each(:as => :hash) works on localhost but not on Heroku

In the Rails code on my computer, I'm writing a pure SQL query (I love SQL) and then parsing the results with:

friends.each(:as => :hash) do |row|

This all works fine, but when I try to push it to Heroku, I get the following error:

ArgumentError (wrong number of arguments(1 for 0)):

And it's complaining about the each loop. Why could this be happening, is Heroku somehow behind, like with an older version of Ruby where you can't do this? Or is it a MySQL vs. PostGreSQL (I'm using MySQL on my computer) thing?

You can use other related syntax like

ActiveRecord::Base.connection.select_rows("select * from friends") which will return result as array of arrays.

or

ActiveRecord::Base.connection.select_values("select * from friends") which will return array for first column values of all the selected records.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM