简写数组中的Ruby变量

时间:2014-02-06 07:38:26

标签: ruby

我正在尝试将变量deploy[:deploy_to]插入到我的速记数组中。

node[:deploy].each do |application, deploy|
    %w[ #{deploy[:deploy_to]}/current/cache 
        #{deploy[:deploy_to]}/current/public/projects_icons ].each do |path|
            directory path do
                user deploy[:user]
                group deploy[:group]
                mode "0777"
            end
       end
end

我该怎么做?

1 个答案:

答案 0 :(得分:0)

%W支持插值:

%W[ #{deploy[:deploy_to]}/current/cache 
    #{deploy[:deploy_to]}/current/public/projects_icons ].each do |path|
        directory path do
            user deploy[:user]
            group deploy[:group]
            mode "0777"
        end
   end