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的列设置成别的列名(比如不存在的某个列). 文 ... 
随机推荐
- xwalk_core_library-15.44.384 .13.aar  百度云分享
			xwalk_core_library-15.44.384.13.aar 这玩意下载很慢 特意放到百度,需要的可以通过百度下载 http://pan.baidu.com/s/1nt0Cmbn 下完后放到 ... 
- docker 启动安装等命令
			确认是否安装url whereis curl 启动docker服务: sudo service docker start sudo service docker stop 安装curl sudo ap ... 
- JavaScript检测对象的类属性
			function classof(o) { if(o === null) { return "Null"; } if(o === undefined) { return " ... 
- [转]CSS如何设置html table表格边框样式
			原文地址:http://www.divcss5.com/wenji/w503.shtml 对table设置css样式边框,分为几种情况: 1.只对table设置边框 2.对td设置边框 3.对tabl ... 
- js中的原型prototype
			var arr1 = new Array(12,34,98,43,38,79,56,1); arr1.sum=function (){ var result = 0; for(var i=0; i&l ... 
- 【bzoj3143】 Hnoi2013—游走
			http://www.lydsy.com/JudgeOnline/problem.php?id=3143 (题目链接) 题意 一个无向连通图,顶点从1编号到N,边从1编号到M.每一步以相等的概率随机选 ... 
- VS2015中SharedProject与可移植类库(PCL)项目
			转自:http://www.tuicool.com/articles/beaMZv3 今天闲里偷空看了点Connect大会的视频,C# 6.0的新语法.EF7的支持非关系型数据库.Windows商店应 ... 
- Bzoj1426 收集邮票
			Time Limit: 1 Sec Memory Limit: 162 MBSubmit: 292 Solved: 232 Description 有n种不同的邮票,皮皮想收集所有种类的邮票.唯一 ... 
- MYSQL索引结构原理、性能分析与优化
			[转]MYSQL索引结构原理.性能分析与优化 第一部分:基础知识 索引 官方介绍索引是帮助MySQL高效获取数据的数据结构.笔者理解索引相当于一本书的目录,通过目录就知道要的资料在哪里, 不用一页一页 ... 
- CSS-学习笔记三
			绝对定位:1. 脱离了文档流,没有浮动效果2. 默认情况下,设置了绝对定位的块,它的Top,left是相对于浏览器的3. 当给设置了绝对定位的块的父元素设置定位的时候(绝对.相对.固定), 那么 ... 
