[Nitro] Nitro/OG examples that show recommended ......

Walter Walter at mwsewall.com
Fri Sep 2 11:08:26 EDT 2005

> > OK.....I did look at that and will experiment with that, 
> but are there "controls" already defined to work with them.  
> i.e Are there text fields that will automatically pull from 
> the defined variable and to prefill the field, and then when 
> posting auto
> matically validates and set the data to the correct field.  
> If there are errors how does it display them? On the same 
> page or is this configurable???
> This is a work in progress. Have a look at the new scaffolding and
> auto admin code. This code does not support validations yet, but this
> will be available shortly. As an example have a look at Flare.

Ahh ok.... I just didn't want to start working on something myself if it was already there, and I jut missed it.
I will look at the above examples.

> > I did look at this and dug deeper into the OG source code.  
> And while it does look like it can handle a legacy schema fairly well,
> > I don't believe it currently works with compound primary 
> keys.  Everywhere in the source it refers to a pk field, it 
> does not seem to allow for an array of these.  Or have I just 
> totally misunderstood something fundamental.
> The next version will feature dynamic finder so you will be 
> able to do this:
> Article.find_by_oid_and_author(2, 'gmosx')
> For the moment you can emulate this:
> def find_by_oid_and_author(oid, author)
>   find(:condition => "oid = #{oid} AND author='#{author}'")
> end
> you can also define the compound sql index:
> class Article
>   sql_index oid, author
> end

The above is fine for querying objects, but it does not work when updating objects.
For instance, I have a legacy schema the has invoice headers in an invoice table and invoice line items in a transact table.

Invoices has_many transact
The transacts do not have an oid or anything like that but are identified by the inv_no of the associated header and a line number.
For me to update or delete any individual line_item I have to use those two fields to uniquely identify them.

I can see, for reporting purposes how I can get the data, I just don't think the sql_index would solve my update issues.

> > Cool....I guess the only part I am missing is how to 
> describe this?  And are there requirements > that they be set 
> in the constructor or can they be set after object creation 
> vie assessor fields.
> > ...

Here I am asking if the sub-object (is there better terminology for this) needs to have its fields settable via a constructor or via accessors, is this configurable?

> > I am missing how I tell OG to map the fields to the 
> sub-object Address contianed by Customer.

I guess I am missing the syntax of how to map the 5 db fields to the fields for the sub-object.  If this will stored in a different table, then I could use has_one or has_many to that, but how is it done within the same table.  I am sure I am just missing a simple piece, I just can't seem to find it.

> I am not sure if this works in legacy schemas, but in normal mode Og
> handles the mapping automatically for you. Then again I am not sure I
> correctly understood your question. I am running a lot today.
> regards,
> George.

I do appreciate your time to answer my questions, it really has been very helpful to me.



No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.10.17/85 - Release Date: 8/30/2005

More information about the Nitro-general mailing list