如何将一组符号提供给委托

时间:2012-10-29 01:21:28

标签: ruby-on-rails ruby

我想做类似的事情:

project_paths = project_hash.keys
delegate :params, :h, :raw, :link_to, project_paths, to: :@view

但是project_paths是一个数组,这在这里不起作用。

如何将符号数组转换为逗号分隔符号的“列表”,我可以将其输入delegate

1 个答案:

答案 0 :(得分:4)

使用splat运算符:

delegate :params, :h, :raw, :link_to, *project_paths, to: :@view