如何在局部 View 中以哈希形式获取所有本地人。
# mainview.html.haml:
= render 'v1', p1: 100, p2: 'some_value', _other_values_
在部分 View 中:
# _v1.html.haml
# do something here...
# render another partial view
= render 'another_view', locals: locals # what to write here???
如何将本地变量中的所有变量作为哈希值访问。
我不想列出所有本地变量。
最佳答案
使用 local_assigns
。
local_assigns #=> { p1: 100, p2: 'some_value', _other_values_ }
_v1.html.haml
= render 'another_view', local_assigns
关于partial-views - Rails 4,让所有本地人部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30137944/