Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relationships, can't use custom name when using $belongs_to? #199

Open
paulcanning opened this issue Mar 10, 2015 · 1 comment
Open

Relationships, can't use custom name when using $belongs_to? #199

paulcanning opened this issue Mar 10, 2015 · 1 comment

Comments

@paulcanning
Copy link

I'm trying to use the built in Relationship features, and it's not letting me use my own name when doing a join.

E.G

public $belongs_to = array('owner' => array('model' => 'user_model', 'primary_key' => 'owner_id'));

This won't work. I get an error saying:

"Unable to locate the model you have specified: user_model"

Even though I have specifically set the model to "user_model"?

If I change the word "owner" to "user" (and also change it in the "with()" command) it works.

@thnaeff
Copy link

thnaeff commented Jul 16, 2015

So I am guessing you have a User_model and a Owner_model. In the User_model you have to define the belongs_to=array('owner'), which then automatically looks for an Owner_model and owner_id. Could it be that you actually define the belongs_to in the Owner_model?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants