我的前端是主幹,前端是Phil Sturgeon的REST控制器的codeigniter。骨幹和codeigniter休息服務器問題
我有一個模型:出版商 和一個集合:出版商
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,如果我只是模擬PUT請求http://pubhub.local/restpublisher/一切工作正常,我想我可以得到請求 - )的參數>放(
是有解決這個問題的方法?
問題2:有人能解釋我爲什麼行動的名稱應該從索引開始? 爲什麼我不能只寫行動:publishers_post保存收集將獲得數據?
非常感謝! Roy
骨幹模型是從集合url繼承的,因此它已經有了url:「/ restpublisher」。這真的不是問題所在......問題是骨幹產生URL http://pubhub.local/restpublisher/1111其中codeigniter期望一個URL:http://pubhub.local/restpublisher沒有附加ID – royB 2013-04-08 12:17:00
該模型沒有繼承任何東西(我不確定術語* inherit *是否適用)。如果未在模型中指定,則在需要時即時評估URL。如果您指定一個,它將不再使用該集合的URL。確切地說你需要的行爲。 – Loamhoof 2013-04-08 12:26:47
我可以查看它,但是因爲我從來沒有使用過CodeIgniter,所以我想這會很慢,因爲我必須先了解REST API的機制。 – Loamhoof 2013-04-08 12:48:54