michalsn/CodeIgniter-AngularJS-App

REST_Controller trying to find save_get instead of save_post

brentreeves opened this issue · 1 comments

Q: is there some configuration parameter I've hosed up to make
REST_Controller::_detect_method return 'GET' instead of 'POST' ?
The first line in _detect_method is:
$method = strtolower($this->input->server('REQUEST_METHOD'));
and it does return 'GET' instead of the expected 'POST'.

The two example projects are stored in database ok and show up in the initial list. "Edit" buttons works fine, but "SAVE" button gets internal server error 500 because REST_Controller is fishing around for "save_get" instead of "save_post" method.

console log shows:
POST http://localhost/cia3/api/projects/save/2 500 (Internal Server Error)

so save/2 is being sent as POST. But REST_Controller returns:

{"status":false,"error":"Unknown method [save_get]."}

script.js has the usual:
...
angular.module('projectApi', ['ngResource']).
factory('Project', function($resource) {
var Project = $resource(BASE_URL+'api/projects/:method/:id', {}, {
query: {method:'GET', params: {method:'index'}, isArray:true },
save: {method:'POST', params: {method:'save'} },
get: {method:'GET', params: {method:'edit'} },
remove: {method:'DELETE', params: {method:'remove'} }
});

Project.prototype.update = function(cb) {
console.log('angular.module Project.prototype.update function cb: ' + cb);
  return Project.save({id: this.id},
      angular.extend({}, this, {id:undefined}), cb);
};

...

Hi,
Sadly I couldn't recreate this error.
You can try setting variable $config['enable_emulate_request'] = TRUE in "config/rest.php" (but it should be already set).
You can report this issue on codeigniter-restserver project.