I have a users model with the following association: “Users hasMany Asset”. My Assets model utilizes an Upload behavior: “Assets actsas Upload”. Is there any way I can set the Upload behavior’s parameters from the User model definition? I want to be able to set the upload path directly from the User model and I’m not sure how to set this.
Ideally I can do the following in my User model, but this doesn’t work:
var $hasMany = Array(
'Asset' => Array(
'classname' => 'Asset',
'foreignKey' => 'foreign_id',
'conditions' => Array('Asset.class' => 'User'),
'dependent' => true,
'Upload' => Array(
'settings' => Array(
'filename' => Array('path' => 'src/users')
)
)
Any ideas?
No. Options you pass specifying the model relationships are limited to the type of relationship. So you will not be able to pass additional Model configuration this way.
You can set this in the Assets model directly or the Users controller.