> On Mon, Sep 28, 2009 at 9:48 PM, bram <
brammele...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> > In my app, I have a User model that has a habtm association with
> > 'Event'. In one of the views, I want to show a list of Users and their
> > most recent event.
>
> > I ended up with this definition in the User model:
>
> > var $hasAndBelongsToMany = array(
> > 'Event' => array(
> > 'className' => 'Event',
> > 'joinTable' => 'events_users',
> > 'foreignKey' => 'user_id',
> > 'associationForeignKey' => 'event_id',
> > 'unique' => true,
> > 'limit' => 1,
> > 'order' => 'Event.date DESC'
> > )
> > );
>
> > find('all') returns the list of all users and only one of them has an
> > associated event.
>
> > When increasing the limit, it does show associated events, but when
> > some user don't have events associated, some other users will have
> > multiple events returned.
>
> > Is this a cake bug or do I have the wrong impression of the limit in a
> > habtm association?
>
> > Cheers,
>
> > Bram