I don't like this option, because I'll have to make sure I have only
one of this group manually. I thought of a validator that will do the
job for me, but it got very complicted.
I acctually had an idea of using IS_IN_DB, but leave the field as an
integer, instead of a reference. Yet, I'm too tierd to try it now.
I'll probably do it in the morning.

On Apr 8, 10:25 am, Seeker <[email protected]> wrote:
> Perhaps just add a boolean field in the chapter table: is_first ... or
> something to that effect??
> On saving an un-flagged chapter you can always check whether any other
> chapters for the story have been flagged as first; if not auto flag
> the one being saved.
> If a subsequent chapter (marked as first) is saved then set all others
> to false.
>
> Not perfect but just a thought...
>
> On Apr 8, 8:05 am,guruyaya<[email protected]> wrote:
>
>
>
>
>
>
>
> > I wanted something more generic to work with, for future uses. But I
> > guess you're right.
>
> > On Apr 7, 11:42 pm, villas <[email protected]> wrote:
>
> > > Why not simply write an onvalidation function?
>
> > > When you save a record with form accepts this would check to ensure
> > > that you only have one first_chapter for that story_id.
>
> > > On Apr 6, 9:29 pm,guruyaya<[email protected]> wrote:
>
> > > > Here's a simplified version of a model I'm working on:
>
> > > > db.define_table('story',
> > > >     Field('title'),
> > > >     Field('description', 'text'),
> > > >     Field('first_chapter', db.chapter)
> > > > )
>
> > > > db.define_table('chapter',
> > > >     Field('title'),
> > > >     Field('tale', 'text'),
> > > >     Field('story_id',db.story)
> > > > )
>
> > > > As you can imagine, I have a problem here. I cannot reference the
> > > > first chapter in the story table, because chapter is not yet defined,
> > > > but I cannot write thetablesbackwards, because story won't be
> > > > defined.
> > > > I was wondering if there's any way of doing this elegantly, or I'll
> > > > just have to count on the first chapter written of any story - to be
> > > > the first chapter.
> > > > Thanks in advance
> > > > Yaya

Reply via email to