我有一个名为rewards_controller的控制器,在那个控制器中我有:
var $name = 'Rewards';
var $uses = array('Membership', 'Product');
在这个控制器中我有这个动作:
function redeemed()
{
//snipped for brevity
$this->paginate = array('conditions' =>
array('Reward.user_id' => $this->Auth->user('id')),
'limit' => 50,
'order' => array('Reward.created' => 'desc'),
'contain' => array('Product' => array('Image' => array('limit' => 1)),
'Status'));
$this->set('rewards', $this->paginate()); // This line causes the warning
}
今天,用户在访问奖励/兑换时开始报告警告。警告是:
Warning (512): Model "Membership" is not associated with model "Product"
[CORE/cake/libs/model/behaviors/containable.php, line 363]
和
Warning (512): Model "Membership" is not associated with model "Status"
[CORE/cake/libs/model/behaviors/containable.php, line 363]
所以这是因为它试图将成员资格链接到产品和状态,但不存在链接/关系。
那么有没有办法告诉paginate()调用只使用奖励模型,而不是使用$ uses中的成员资格模型?
答案 0 :(得分:0)
问题在于你$uses
。在V1.3中,the name of the current controller’s model must also be included。
将您的“原始代码”更改为:
var $uses = array('Reward', 'Membership', 'Product');