RubyOnRails local_assigns
http://api.rubyonrails.org/classes/ActionView/Template.html#method-i-local_assigns
Returns a hash with the defined local variables.
Given this sub template rendering:
<%= render "shared/header", { headline: "Welcome", person: person } %>
You can use local_assigns in the sub templates to access the local variables:
local_assigns[:headline] # => "Welcome"
current_index = local_assigns[:index] || default_index
from = (local_assigns[:from] || default_from) + ["#{current_index}:#{component.name}"]
version = :v4
json.array! component.get_parts_in_order(@status).each_with_index.to_a do |part, index|
json.partial! 'api/v2/components/component', component: part, from: from, index: index
end
RubyOnRails local_assigns的更多相关文章
- ubuntu安装rubyOnRails
https://gorails.com/setup/ubuntu/16.04#ruby-rbenv 文章很详细
- Rails Array method second/third/second_to_last
http://api.rubyonrails.org/classes/Array.html#method-i-second [27] pry(main)> list = ["a&quo ...
- Rails sanitize
The SanitizeHelper module provides a set of methods for scrubbing text of undesired HTML elements. T ...
- CentOS安装gitLab服务器
首先利用gitlab-install-el6.sh安装,比较简单: (出处:http://www.linuxidc.com/Linux/2013-06/85754.htm) 1:如果有条件,提供一台全 ...
- iteye上总结的编程精华资源
原文:http://www.iteye.com/magazines/130 博客是记录学习历程.分享经验的最佳平台,多年以来,各路技术大牛在ITeye网站上产生了大量优质的技术文章,并将系列文章集结成 ...
- [COPY] How to become a hacker
Engish version copied from here Why This Document? As editor of the Jargon File and author of a few ...
- 初识Docker和Windows Server容器
概览 伴随着Windows Server 2016 Technical Preview 3 (TP3)版本的发布,微软首次提供了Windows平台下地原生容器.它集成了Docker对Windows S ...
- rails enum用于存储数据
http://api.rubyonrails.org/classes/ActiveRecord/Enum.html 新的项目中有一个字段是展示类型,可以用下拉框去做,用string存储具体的类型字段. ...
- single-table inheritance 单表继承
type 字段在 Rails 中默认使用来做 STI(single-table inheritance),当 type 作为普通字段来使用时,可以把SIT的列设置成别的列名(比如不存在的某个列). 文 ...
随机推荐
- [LeetCode] Logger Rate Limiter 记录速率限制器
Design a logger system that receive stream of messages along with its timestamps, each message shoul ...
- IO流
流的概念和作用 学习JavaIO,不得不提到的就是JavaIO流. 流是一组有顺序的,有起点和终点的字节集合,是对数据传输的总称或抽象.即数据在两设备间的传输称为流,流的本质是数据传输,根据数据传输特 ...
- 小谈Jquery框架
现在Jquery框架对于开发人员基本上是无人不知,无人不晓了,用起来十分的方便,特别是选择器十分强大,提高了我们的开发速度.但是好多人也只是停留在了会用的基础上,我个人觉得会用一个框架不算什么,只能说 ...
- C程序设计语言学习笔记
在Windows下运行C语言程序 Windows下的编程工具使用 VC 6.0,下面讲解如何在VC 6.0下运行上节的"Hello, world"程序. 1) 新建Win32 Co ...
- JS:window.onload的使用
1.最简单的调用方式 直接写到html的body标签里面,如: (html) (body onload="func()") (/body) (/html) 2.在JS语句调用 (s ...
- IDEA快捷键
[常规] Ctrl+Shift + Enter,语句完成 "!",否定完成,输入表达式时按 "!"键 Ctrl+E,最近的文件 Ctrl+Shift+E,最近更 ...
- 冰冻三尺非一日之寒--还是web
第十五章 javascript(js) DOM编程 javascript介绍 JavaScript是一门编程语言,浏览器内置了JavaScript语言的解释器,所以在浏览器上按照JavaScript ...
- C#设计模式
自从上次记录完“重构之道”以后,查询设计模式挺麻烦的.就打算把原先写的设计模式系列合并一下. 设计原则 使用设计模式的根本原因就是适应需求变化,提高代码的复用率,使程序更具有扩展性和可维护性. SOL ...
- BZOJ2730: [HNOI2012]矿场搭建
传送门 图的连通性相关的必和割点割边之类的有关. 题目要求对于一个无向图,任意一点被删除后,所有点都和某些指定点是联通的. 这道题比较简单的做法就是求出来所有的块.对于一个块,如果块里有两个及两个以上 ...
- iframe的sandbox使用
sandbox:限制iframe的权限,解决安全性问题. 定义 如果被规定为空字符串(sandbox=""),sandbox 属性将会启用一系列对行内框架中内容的额外限制.sand ...