Ember不在destroyRecord()上发送DELETE(Ember not sending a DELETE on destroyRecord())

编程入门 行业动态 更新时间:2024-10-27 12:41:23
Ember不在destroyRecord()上发送DELETE(Ember not sending a DELETE on destroyRecord())

有问题让activeModelAdapter在.destroyRecord上发送DELETE请求,我也尝试.deleteRecord与.save(),但得到相同的结果....

我已经安装了rack-cors gem,所以我的api已经超出了跨源请求

错误:

在2015-04-20 17:51:05 -0700开始选择“/ brands / 117”为:: 1> ActionController :: RoutingError(没有路由匹配[OPTIONS]“/ brands / 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>

Having issues getting the activeModelAdapter to send a DELETE request on .destroyRecord, I also tried .deleteRecord with .save(), but get the same results....

I already have installed the rack-cors gem, so my api is already excepting cross-origin requests

ERROR:

Started OPTIONS "/brands/117" for ::1 at 2015-04-20 17:51:05 -0700> ActionController::RoutingError (No route matches [OPTIONS] "/brands/117"):

BRANDS CONTROLLER:

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') });

BRANDS TEMPLATE:

<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>

最满意答案

所以经过一些搞乱后我发现我没有在RACK :: Cors配置中包含:delete方法,大声笑..现在好了!

So after some messing around I figured out I had not included the :delete method in RACK::Cors config, lol.. All good now!

更多推荐

本文发布于:2023-07-27 14:19:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1291674.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:destroyRecord   Ember   sending   DELETE

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!