3

このようなコードがあります

ssh_files = ["id_rsa.pub","id_rsa"]
ssh_files.each_with_index do |item, index|
      ssh_files[index] =  generate_ssh_path(creator).concat(item)
      FileUtils.mkdir_p(ssh_files[index], 0770) unless File.exists?(generate_ssh_path(creator))

終了すると、このエラーメッセージが表示されます

TypeError (can't dup Fixnum):
  command.rb:45:in `block in generate_ssh_key'
  command.rb:42:in `each'
  command.rb:42:in `each_with_index'

編集ここにスタックがあります

TypeError (can't dup Fixnum):
  command.rb:44:in `block in generate_ssh_key'
  command.rb:42:in `each'
  command.rb:42:in `each_with_index'
  command.rb:42:in `generate_ssh_key'
  key.rb:14:in `create_key'
  key.rb:10:in `initialize'
  app/models/user.rb:207:in `new'
  app/models/user.rb:207:in `ssh_key'
4

1 に答える 1

4

のオプションmkdir_pHash、さまざまなオプションを受け入れるため、次のように呼び出す必要があります。

FileUtils.mkdir_p(ssh_files[index], :mode => 0770)
于 2013-10-03T18:17:33.343 に答える