Forum: Ruby on Rails Using data from a query fired in rails

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
7392f9e85b8e0636276a7074faee44fa?d=identicon&s=25 athind (Guest)
on 2007-05-23 08:31
(Received via mailing list)

I have a query that returns a single number that I want to use further
in my program.

Could you please let me know how I could access the data inside the
object returned by the query.

I invoke it as:

numscens = Progressions.find_by_sql("select numscenarios from
progressions where id = #{params[:progressionid]}

The data in numscens that I get is  >> numscenarios.to_xml:

<?xml version="1.0" encoding="UTF-8"?>
    <numscenarios type="integer">2</numscenarios>

I want to access the number in the numscenarios tag.

Apologies for the novice question.

Many Thanks,
72eb65fa089082d3bd8b38a5596ad331?d=identicon&s=25 Keynan Pratt (keynan)
on 2007-05-23 09:55
What is numscenarios? if it is a column name then you should be able to
access it like any active record find. NOTE: you can't update unless you
have the id field.
This topic is locked and can not be replied to.