Rails permit params 接受Hash,Array
2019独角兽企业重金招聘Python工程师标准>>>
describe 'nested attributes on articles (which has_many comments)' dobefore do@hash = {"article" => {"title" => "Test","body" => "test body","comments_attributes" => {'0'=>{"author" => "John", "content" => "great"},'1'=>{"author" => "Mary", "content" => "awful"}}}}@params = ActionController::Parameters.new @hashendit 'shows how to permit nested parameters' doattributes = @params.require(:article).permit(:title, comments_attributes: [:author,:content])[:comments_attributes].must_equal @hash['article']['comments_attributes']end end
http://www.carreno.me/articles/understanding-strong-parameters-in-rails-4
转载于:https://my.oschina.net/u/923974/blog/789465
Rails permit params 接受Hash,Array相关推荐
- perl hash array 嵌套 push
$hash{"A"}=["pp"]; 想变成: $hash{"A"}=["p","q"]; 因为 $ ...
- rails parameter permit
公共许可证(*过滤器) 返回一个新的ActionController::Parameters实例,该实例只包含给定的筛选器,并将对象的允许属性设置为true.这有助于限制应允许哪些属性进行大规模更新. ...
- 第四章 Rails 背后的 Ruby
第四章 Rails 背后的 Ruby 有了第三章中的例子做铺垫,本章将为你介绍一些对 Rails 来说很重要的 Ruby 知识.Ruby 语言的知识点很多,不过对一个 Rails 开发者而言需要掌握的 ...
- Rails下cloud datastore的使用
Rails下cloud datastore的使用 背景 部门有一个项目要用Ruby做 WebAPI,DB使用关系型数据库Cloud Sql和非关系型数据库Cloud Datastore . 还不了 ...
- Rails Model
Rails Model https://guides.rubyonrails.org/ https://api.rubyonrails.org/ 第一次写于 : 2020年3月22日 忙碌了一段时间, ...
- Ruby on rails 实战圣经:Part 2: 深度剖析环境设定与Bundler
Complication is WhatHappens When You Try to Solve a Problem You Don't Understand - Andy Boothe 目录结构 ...
- rails 代码结构详解
目录结构 这一节让我们走访一个 Rails的目录结构: app/ app 目录是你主要工作的地方,不同子目录存储了 Models.Controllers.Views.Helpers和 Assets 等 ...
- Ruby on rails 实战圣经: 深度剖析环境设定与Bundler
Complication is WhatHappens When You Try to Solve a Problem You Don't Understand - Andy Boothe 目录结构 ...
- nginx学习——建立hash表的前提条件
在前面两篇博文中分别介绍了nginx中普通hash表和带有通配符的hash表的建立和查找,今天主要是介绍建立hash表的前提条件,并在后面附上一个完整的hash表的实现(该部分代码为转载). 一.建立 ...
最新文章
- ssas 为绑定指定的大小太小,导致一个或多个列值被截断
- SSL 握手协议详解
- SQLBackupAndFTP The server principal NT AUTHORITY\SYSTEM is not able to access the database xxxx
- 【SSH】禁用root远程、修改ssh端口
- SOC/LM在台湾的2011年发展趋势研判
- 面向机器学习的特征工程翻译版
- 20135320赵瀚青LINUX第四章读书笔记
- 组件化h5活动模板的实现
- MDT2010部署之二配置MDT2010
- PAT_B_1012_Java(20分)
- linux uniq命令_如何在Linux上使用uniq命令
- 纯干货:Linux抓包命令集锦(tcpdump)
- [Unity][FlowCanvas] FlowScript 实现切换当前 CineMachine 摄像机
- HTML基本功之文档结构
- 魅族“携手”京东,背后有何意图?
- centos安装uWSGI失败处理办法Exception: you need a C compiler to build uWSGI
- Unity-VR | AR相关(更新中)
- plecs用C-SCRPT搭建多路开关。
- [几何] BZOJ 2710 [Violet 1]追风者 POJ 3924 Tornado
- 幽一把默:想摸个一筒,竟是个一筒!