OT: AR difficulties (was Re: [Nitro] Og update)

craig duncan craig-duncan at earthlink.net
Thu Apr 21 23:41:57 EDT 2005

James Britt wrote:

> Ironic that you might get a better Rails answer on the Nitro list, but 
> here goes:
> Rails has find_by_sql:
>     sql = "select t.* from tags t  where t.tag in ( #{tag_set_str} ) "
>     tags = Tag.find_by_sql( sql )
> # Now tags has a set of Tag objects.

I knew about find_by_sql.  I don't think that gives me what i'm looking for, though, 
as it returns (in this instance) Tag objects which map directly to the "tags" table. 
  My desire is not to have my objects limited to having to map directly to a db table 
because my sql query will do joins that pull values from multiple tables.  I just 
can't get my head around AR because there is zero documentation at the right level 
and because of all the magic (using const_missing and method_missing everywhere).  I 
think maybe i'll just learn PHP.  :-)  This is seriously off-topic, but i think ruby 
magic takes the difficulty of understanding how an application works (absent good 
documentation) to a significantly higher level than what i'm used to with C/C++.

> I have a Rails app that is probably 90% SQL, as the API associations were
 > simply too weak to get me what I wanted. ... and in retrospect I don't see
 > that using Rails gained me much (other than an education in Rails).
...the *one* thing that keeps me going with this... even though what i'm
trying to do sounds very similar to what you described:

> With about the same amount of effort I could have 
> simply done the O/R mapping myself and just writing a fairly 
> straightforward database-backed Web service.  And have fewer files 
> laying around.
> because I already know and have the data, I need to hand code the 
> SQL, and I'm just rendering result sets in assorted markup based on 
> various queries.  There are very few objects, and there is very little 
> business logic; it's mostly "Look this up and wrap RDF around the results."


More information about the Nitro-general mailing list