【发布时间】:2013-04-08 11:11:19
【问题描述】:
我的前端是主干,前端是带有 Phil Sturgeon 的 REST 控制器的 codeigniter。
我有一个模型:Publisher 和一个集合:Publishers
App.Collections.Publishers = Backbone.Collection.extend({
model: App.Models.Publisher,
url: '/restpublisher'
});
我的 RestPublisher 控制器有:
function index_post(){
$this->response('in pulisher_post');
}
function index_delete(){
$this->response('in pulisher_delete');
}
function index_put(){
$this->response('in pulisher_put');
}
问题在于 this.model.save();触发的 url 是:http://pubhub.local/restpublisher/1111 其中 1111 是 id。
问题是我得到 404。如果我只是模拟对 http://pubhub.local/restpublisher/ 的放置请求,一切正常,我想我可以从 request->put() 获取参数
有没有办法解决这个问题?
问题2:谁能解释一下为什么action的名字应该以index开头? 为什么我不能只写操作:publishers_post 保存集合时会获取数据?
非常感谢! 罗伊
【问题讨论】:
标签: php codeigniter backbone.js