在让activeModelAdapter在.destroyRecord上发送DELETE请求时遇到问题,我也尝试.deleteRecord与.save(),但得到相同的结果....
我已经安装了rack-cors gem,所以我的api已经超出了跨源请求
错误:
在2015-04-20 17:51:05 -0700>上为:: 1启动OPTIONS“/ brands / 117” ActionController :: RoutingError(没有路由匹配[OPTIONS] “/品牌/ 117”):
品牌控制器:
export default Ember.ArrayController.extend({
needs: 'application',
currentUser: Ember.computed.alias('controllers.application.currentUser'),
currentPath: Ember.computed.alias('controllers.application.currentPath'),
actions: {
deleteBrand: function(brand) {
brand.destroyRecord();
}
},
showButton: function() {
return this.currentPath === 'brands';
}.property('controllers.application.currentPath')
});
品牌模板:
<h2>Brands</h2>
{{#if showButton}}
{{#link-to 'brands.new' class="bam-btn submit login" tagName="button"}}Create A Brand{{/link-to}}
{{/if}}
{{outlet}}
{{search-brands}}
{{!-- LIST OF BRANDS --}}
<h2 class="bam-clear">List of {{ controllers.application.currentUser }} brands</h2>
<ul>
{{#each brand in model}}
{{#link-to 'brand.dashboard' brand.slug}}
<li><h3>{{brand.brand_name}}</h3></li>
<button id="deleteBrand" class="bam-btn alert" {{action 'deleteBrand' brand}}>Delete</button>
{{/link-to}}
{{/each}}
</ul>
答案 0 :(得分:0)
所以经过一些搞乱我发现我没有在RACK :: Cors配置中包含:delete方法,大声笑..现在好了!