gpt4 book ai didi

ruby-on-rails - Rails 复制了资源中的参数

转载 作者:行者123 更新时间:2023-12-03 07:35:15 27 4
gpt4 key购买 nike

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

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

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

重复是因为欢迎使用 Stackoverflow,在那里你需要 50 点评论所以这会发生。真的很抱歉: AngularJS $resource sending out an extra "registration" hash?

最佳答案

..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 散列中输入内容的默认方式。

关于ruby-on-rails - Rails 复制了资源中的参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27672954/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com