0
您好我正在使用rails和angularjs與angularrailsresource寶石。我需要對我定義的名爲'Comment'的rails資源進行自定義發佈請求。我嘗試使用$ post方法是這樣的:自定義帖子使用角軌資源
Comment.$post('some_method', {comment_id: comment.id, username: username, type: 'mention'}).then(function(result){
console.log(result);
});
,它使一個請求,但它總是使得我在頁面的根目錄下。所以我想提出一個要求,以「/評論/」,但它試圖讓一個請求「/病人/ some_method」,如果我這樣做:
Comment.$post('comments/do_stuff', {comment_id: comment.id, username: username, type: 'mention'}).then(function(result){
console.log(result);
});
它會嘗試發佈到「病人/評論/ some_method',或者其他任何我所在頁面的根目錄。有沒有辦法告訴它直接發佈資源,而不是通過我目前的url上下文?感謝您的幫助。