Saturday, February 25, 2012

Re: problems with belongsTo and hasMany...

PS: This happens with Cake 2.0

I "installed" cake 1.3 and this error doesnt happen. There is any
change of convention? Any bug about it?

On 24 feb, 09:36, Miguel Ángel Moreno Armenteros
<miguel.s.addr...@gmail.com> wrote:
> I also did :-( it is so frustrating... because the amount of code is
> absurd!
>
> i also tried with the array like
>
> $belongsTo = array(
>      'User' => array(
>           classname => ,,,,
>      )
> )
>
> etc
>
> On 23 feb, 10:22, Stephen <step...@ninjacodermonkey.co.uk> wrote:
>
>
>
>
>
>
>
> > try the following:
>
> > $hasMany = array('Profile');
>
> > $belongsTo = array('User');
>
> > Cheers
>
> > On 22 February 2012 19:02, Miguel Ángel Moreno Armenteros <
>
> > miguel.s.addr...@gmail.com> wrote:
> > > Hello, i know this subject comes over and over but I couldnt find the
> > > solution..
> > > Im a beginner and iam testing out some scaffolding and so on.
>
> > > I have Profiles of user and Users, who belong to a certain profile.
> > > for that i have two tables
>
> > > users
> > >    id int not null auto_increment primary key
> > >    username
> > >    name
> > >    profile_id
> > > .....
>
> > > profile
> > >  id
> > >  profile
>
> > > in the models i have this
> > > profile.php
>
> > > <?php
> > > class Profile extends AppModel{
> > >        var $name = 'Profile';
> > >        var $hasMany = 'User';
> > > }
> > > ?>
>
> > > user.php
>
> > > <?php
> > > class User extends AppModel{
> > >        var $name = 'User';
> > >        var $belongsTo = 'Profile';
> > > }
> > > ?>
>
> > > and the controllers
>
> > > profiles_controller.php
> > > <?php
> > > class ProfilesController extends AppController{
> > >        var $name = "Profiles";
> > >        var $scaffold;
> > > }
>
> > > ?>
>
> > > users_controller.php
> > > <?php
> > > class UsersController extends AppController{
> > >        var $name = 'Users';
> > >        var $scaffold;
> > > }
>
> > > ?>
>
> > > and when i open /localhost/.../users/add
>
> > > in the formulary it scaffolds, the select field for profile is
> > > empty... so it doesnt recognize the association...
>
> > > can anyone help me with this basic thing??? I checked other examples
> > > and they are like mine!
>
> > > thank you
>
> > > PD: In the database i have some sample profiles already....
>
> > > --
> > > Our newest site for the community: CakePHP Video Tutorials
> > >http://tv.cakephp.org
> > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp
> > > others with their CakePHP related questions.
>
> > > To unsubscribe from this group, send email to
> > > cake-php+unsubscribe@googlegroups.com For more options, visit this group
> > > athttp://groups.google.com/group/cake-php
>
> > --
> > Kind Regards
> >  Stephen
>
> >  http://www.ninjacodermonkey.co.uk

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: