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] Number of 1 Bits 位1的个数
Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also know ...
- [LeetCode] Plus One 加一运算
Given a non-negative number represented as an array of digits, plus one to the number. The digits ar ...
- 如何用Azure Web App Services接入微信公众号
注:本文提到的代码示例下载地址>如何用Azure Web App Services接入微信公众号 如何用Azure Web App Services接入微信公众号 简介 此示例演示如何创建Azu ...
- Socket通信类
package com.imooc; import java.io.BufferedReader; import java.io.IOException; import java.io.InputSt ...
- ubuntu下的apt-get内网本地源的搭建
APT本地源的搭建(可用于局域网apt-get源搭建或者本地源) 本文档介绍使用apt-mirror软件搭建apt本地源 需求:内网开发环境由于其特定原因不能上外网,所以需要本地环境下的内网源来方便开 ...
- Redis 常用操作
import org.junit.Before;import org.junit.Test;import redis.clients.jedis.Jedis;import java.util.Set; ...
- js压缩xml字符串,将xml字符串转换为xml对象,将xml对象转换为json对象
/** * 压缩xml字符串 */ function compressXmlStr(str){ var prefix, suffix; var i = str.indexOf("\r&quo ...
- 命令行工具aspnet_regiis.exe实现加密和解密web.config
命令行工具aspnet_regiis.exe,是一个类似于DOS的命令工具,称之为命令解释器.使用命令行工具加密和解密web.config文件中的数据库连接字符串时,只需要简单的语法命令即可. 加密语 ...
- django 进阶篇
models(模型) 创建数据库,设计表结构和字段 使用 MySQLdb 来连接数据库,并编写数据访问层代码 业务逻辑层去调用数据访问层执行数据库操作 import MySQLdb def GetLi ...
- hibernate- Hibernate中多对多的annotation的写法(中间表可以有多个字段)
http://blog.csdn.net/liuxianbing119/article/details/7283769