Help! Beginner in Ruby

Hi guys.
I’m beginner in Ruby, and I’m using for automated tests.

I’m trying to connect SQL to my application.

I need to know how can I transform a vector into a variable. My query returns just 1 row, but I need to turn this vector into a variable.

client = => "xxx", :username => "xxx", :password => "xxx", :database => "xxx")
sqllistar = client.query("SELECT Placa FROM f001_frotas WHERE Placa regexp '^[A-z]' order by rand() LIMIT 1")

I could print the result doing like this:

sqllistar.each(:as => :array) do |row|
puts row

But I need to put the returned value in a variable to use in a method. How can I do that?
Sorry for my English, I’m brazilian.

it looks like the result object includes enumerable try:

puts sqllistar.first

note if a query returns more rows when expecting just one, #first may return the row you didn’t inspect.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs