[Nitro] OG automatically adding Foreign Key constraints

Tim Larson tim at keow.org
Tue Nov 29 09:47:29 EST 2005


On Tue, Nov 29, 2005 at 02:43:49PM +0000, Tim Larson wrote:
> On Tue, Nov 29, 2005 at 03:47:26PM +1300, Isaac Devine wrote:
> > When using belongs_to and has_many Og isn't generating Foreign Key
> > Constraints :
> > 
> > class Example1
> >  property :name, String
> >  has_many :children, Example2
> > end
> > 
> > class Example2
> >  property :address, String
> >  belongs_to :parent, Example1
> > end
> > 
> > What am I doing wrong? 
> > Failing that is there a way I specify the constraints?
> 
> Because the relation name ":children" does not match the name of
> the related class "Example2" Og is getting lost...change your
> "has_many" line like this to give it the clue it needs:
>   has_many :children, Example2, :foreign_name => :parent

I think my explanation was wrong...the problem is because the name of
relation ":children" does not match the name used in the belongs_to
relation ":parent", but you probably figured that out from the example
has_many line above.

--Tim Larson



More information about the Nitro-general mailing list