首页 > 其他 > 详细

RubyOnRails local_assigns

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

 

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!