Search code examples
rubycapistrano

Capistrano - method_missing map


My deploy script throw error. I use capistrano and gem railsless-deploy

Error: /var/lib/gems/1.9.1/gems/capistrano-2.15.5/lib/capistrano/configuration/namespaces.rb:193:in `method_missing': undefined method `map' for #<Capistrano::Configuration::Namespaces::Namespace:0x00000001a634b0> (NoMethodError)

My Capfile

require 'rubygems'
require 'railsless-deploy'
# load 'deploy'

load 'app/config/deploy'

My deploy.rb

#...more code...#
set :myfiles, ["path/to/file.ext","path/to/another/file.ext"]
#...more code...#
namespace :myfiles do
    task :check do
        myfiles.map do |file|
            #...more code...#
        end
    end
end

ruby -v ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]

cap -V Capistrano v2.15.5


Solution

  • You have a variable myfiles and then the scope a few lines later overrides that. That's why capistrano tries to send the map method to the namespace and fails. Change the list's name to something else like:

    set :file_list, ["path/to/file.ext","path/to/another/file.ext"]
    #...more code...#
    namespace :myfiles do
        task :check do
            file_list.map do |file|
                #...more code...#
            end
        end
    end