I have deleted everything about books_users table! Deleted model,
deleted controller and even view.
And $this->Book->BooksUser->save(...) work perfectly. Why??

On 8 Ago, 18:38, cricket <[email protected]> wrote:
> On Sun, Aug 8, 2010 at 10:16 AM, Mariano C. <[email protected]> 
> wrote:
> > I have books and users table. Both tables have id field as PK, and
> > both have respective Book and User model and controllers.
>
> > There's a third table called books_users, this table have an id field
> > as PK and two FK called user_id and book_id.
>
> Do you really need the PK? If so, see the bottom of this 
> page:http://book.cakephp.org/view/85/Saving-Related-Model-Data-HABTM
>
> > There's a lot of books in the books table, and logged in user can
> > choice to add a book to his collection, to do this is necessary to add
> > a row on books_users table with choosen book's id and logged in user's
> > id.
>
> > Actually I do this through a function add() in the controller
> > BooksUsersController and relative view and model (BookUser).
> > There's a smarter way to do this.
>
> I would put the code in the BooksController, personally. There's no
> need to use a separate controller, and BooksController doesn't have to
> have BooksUsers in the $uses array because you can just go through the
> association. eg:
>
> $this->Book->BookUser->save(...)

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to