How-To: Create a REST API

Comparing #13 with #14

Revision #14 was created by jwerner jwerner on Jan 9, 2012, 11:00:15 PM.

Added note about logged-in user (Yii::app()->user)

Content

[...]
// ...
$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()
[...]