CakePHP: Cake Bake HasOne association
I use the following db setup:
users:
- id
- name
- country_id (FK)
countries
- id
- name
I use this setup for data integrity. W开发者_如何学运维hen a user adds an account, a country dropdown is presented in the add form through a find(list).
The problem is that while Cake Baking, I can not choose a HasOne relationship between users and countries. I can only choose that a User BelongsTo a country.
What goes wrong here? Do I need to add the HasOne association manually or is the BelongsTo relationship correct?
Thanks
I assume you mean hasMany, as in a country has many users. Yes, you'll have to define that in Country model, if you wish to have that relationship.
精彩评论