Manipulate retrieved database find query object, multiple tables and one legacy database (phew)

Hi, First, I am forced to use a legacy database. My problem is that I need data from two separate tables which I can get easily enough separately. What I do need to know is how to join that information together so I can send the result as one xml result.

I.e. from one query I get (after render to xml) <components type="array">   <component>     <componentid type="integer">1</componentid>     ...     <name>Blah</name>   </component>   <component>   ...   </component> </components>

And want to add an item <version>some version string</version> which is data from a 'version' table into that above result

so the result would look sorta like <components type="array">   <component>     <componentid type="integer">1</componentid>     ...     <name>Blah</name>     <version>1.2.3.4</version>   </component>   <component>   ...   </component> </components>

Now I can't really use association since it's a legacy database and the 'id' in the 'component' table in MySQL does not correspond to a 'version_id' column in the 'version' table as there is no 'version_id'.

Is my only choice using XML Builder? Or can I manipulate the object retrieved from the database find queries and send it straight to render xml?

Or am I missing something really simple?

Just more info... I'm trying this query find_by_sql("SELECT components.logicalname, versions.level, versions.branch, versions.sequence from components, versions WHERE components.componentid = '" + componentid + "'" + " AND versions.componentid = '" + componentid + "'")

Ugly but seems to work from mysql but from the console (netbeans) it only outputs components.logicalname and nothing from versions.level, versions.branch and versions.sequence

Why would the output be different? Any ideas?

because what you see in the console (ie what the inspect method returns) is hardwired just to show attributes from that table. The other ones (branch etc..) are there (try calling them) they're just not displayed. You could also try using to_xml's :methods option. I wouldn't say builder is a big deal, I'd far rather some nice clean builder than a bunch of contorted stuff to squeeze the right thing out of to_xml

Fred

Thanks, it seems it was a display problem. It's working now. I'll see about making it cleaner with builder next. Again, thanks, greatly appreciated.

Hubert