I am certain this is very simple, but I'm a noob to Ruby and can't seem to find the answer to a very basic question.
I have a table with a list of words in PostgreSQL. I am getting a return value from a query to get a count of rows. When I try to assign this returned value to a variable "wordcount," I can't seem to get just the integer value. For example, if I try to use wordcount (as obtained below), Ruby throws an error "can't convert Array into Integer (TypeError)." In short, how do I convert the value obtained from the query to an integer? Thanks in advance.
q = 'SELECT COUNT(*) FROM words'
res = conn.exec(q)
wordcount = res.values[0]
puts wordcount