Example:
result = ActiveRecord::Base.connection.execute("select 'ABC'")
How can I get the 'ABC' value from result? Tried result.first without success. Thanks
p.s. Gems:
activerecord (2.3.9)
mysql (2.8.1)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could try it on the cosole:
enter your code in the console and you get:
irb> result = ActiveRecord::Base.connection.execute("select 'ABC'") => [{0=>"ABC", "'ABC'"=>"ABC"}]so it you get it with
result.firstjust returns the first row, not the first value. This row consists of a Hash with numerical and named access.