Previously I have used mysql RubyGem in my app. Now I have switched to mysql2 RubyGem and I'm having problems with Result class.
Code example:
db_values = ActiveRecord::Base.connection.execute(sql)
db_values.each_hash do |db_value|
ret_val << MyValue.do_smth_with_data(db_value)
end
Previously (in mysql RubyGem) there was each_hash method for looping through the data. In mysql2 RubyGem there is just a 3 possible methods (count, each, fields) for Result class and one of them is each method, but that is not what I need to loop fetched data.
Any suggestion?
the mysql2 gem includes the Enumerable module, so you just use each instead of each_hash.
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