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)
And want to add an item
some version string
which is data from a ‘version’ table into that above result
so the result would look sorta like
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
Is my only choice using XML Builder? Or can I manipulate the object
retrieved from the database find queries and send it straight to
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?
On Aug 26, 12:06 am, cinderedmonkey [email protected]
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
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.