Revision #14 has been created by jwerner on Jan 9, 2012, 11:00:15 PM with the memo:
Added note about logged-in user (Yii::app()->user)
« previous (#13) next (#15) »
Changes
Title
unchanged
How-To: Create a REST API
Category
unchanged
How-tos
Yii version
unchanged
Tags
unchanged
REST, API, Tutorial
Content
changed
[...]
// ...
$this->_sendResponse(500, $msg );
}
```
Please keep in mind to check your model `beforeSave` and `afterSave` methods if any code eventually uses a logged-in user's id like the blog `Post` model:
```php
protected function beforeSave()
{
...
// author_id may have been posted via API POST
if(is_null($this->author_id) or $this->author_id=='')
$this->author_id=Yii::app()->user->id;
...
}
```
### Delete a Model Action
```php
public function actionDelete()[...]