码迷,mamicode.com
首页 > 其他好文 > 详细

RubyOnRails local_assigns

时间:2016-12-21 13:56:32      阅读:194      评论:0      收藏:0      [点我收藏+]

标签:ble   this   lin   render   status   view   get   bsp   variables   

 

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

标签:ble   this   lin   render   status   view   get   bsp   variables   

原文地址:http://www.cnblogs.com/iwangzheng/p/6207358.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!