createAbsoluteUrl() Issue

I’m using createAbsoluteUrl to generate an activation URL for new users, but am getting the following error:

Recoverable error

Object of class SiteController could not be converted to string

The code usage is as follows:




if ($model->save(false))

{

    $url = $model->$this->createAbsoluteUrl('activation/validatekey', array('key'=>$model->activationKey));

    //TODO: send activation e-mail

}



This is happening within the controller the error is referencing, leaving me a bit baffled as to where it is being ‘converted to string’. Any tips are appreciated! Thank you.




// wrong

$model->$this->createAbsoluteUrl() <img src='http://www.yiiframework.com/forum/public/style_emoticons/default/huh.gif' class='bbc_emoticon' alt='???' />

// correct 

Yii::app()->createAbsoluteUrl();

// OR

$this->createAbsoluteUrl(); // if in view file or controller.



You have an extra "$model->" in there. Try:

$this->createAbsoluteUrl(…);

instead of

$model->$this->createAbsoluteUrl(…);

Thank you both for the quick replies. I was working off of an example that had the extra $model in there curiously.

I wonder if his/her code worked :D

Again, much appreciated.