簡體   English   中英

紅寶石不能重復Fixnum

[英]ruby can't dup Fixnum

我有一些像這樣的代碼

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'

mkdir_p選項應該是Hash ,因為它接受各種選項,所以這樣稱呼它:

FileUtils.mkdir_p(ssh_files[index], :mode => 0770)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM