Rails复制了资源内部的参数 [英] Rails duplicated the parameters inside the resource

查看:99
本文介绍了Rails复制了资源内部的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Angular Resource,但我不明白为什么Rails复制参数并将其放在资源名称中.我只需要了解为什么会发生这种情况.

I am using the Angular Resource and I don't understand why Rails duplicated the parameters and put it inside the resource name. I just need to understand why this is happening.

// post data
{"title":"asdsad"}

// rails parameters 
Parameters: {"title"=>"asdsad", "presentation"=>{"title"=>"asdsad"}}

重复,因为欢迎来到Stackoverflow,在这里您需要50点评论,因此会发生这种情况.我真的很抱歉: AngularJS $ resource发送了一个额外的注册"消息;哈希?

Duplicate because welcome to Stackoverflow where you need 50 points to comments so this happen. I really so sorry: AngularJS $resource sending out an extra "registration" hash?

推荐答案

..如果已在初始化程序中打开config.wrap_parameters [请检查文件 config/initializers/wrap_parameters.rb]或[您]正在呼叫 控制器中的wrap_parameters()...参数将被克隆并 默认情况下,根据您的控制器名称将其包装在密钥中.

..if you've turned on config.wrap_parameters in your initializer [check the file config/initializers/wrap_parameters.rb] or [you] are calling wrap_parameters() in your controller...the parameters will be cloned and wrapped in the key according to your controller's name by default.

http://guides.rubyonrails.org/action_controller_overview.html#parameters http://api.rubyonrails.org/classes/ActionController/ParamsWrapper.html

换句话说,您所看到的是Rails在params哈希中输入内容的默认方式.

In other words, what you are seeing is the default way rails enters things in the params hash.

这篇关于Rails复制了资源内部的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆