2014-03-26 44 views
-3

如何將fixnum轉換爲ruby中的數組?將Fixnum轉換爲ruby中的數組

例如:


s = SituationType.all(:conditions => {:name => 'did not match retrieved design - text misspelled'}).collect(&:id) 
result: [10034, 10055]

sf = situation_type_id = SituationType.find_by_name('did not match retrieved design - text misspelled').id result: 10034

s -sf says, TypeError: can't convert Fixnum into Array

回答

2

執行以下操作

s - [sf] 

由於SF是一個整數,它不能,除非你把它轉換成一個數組做減法

相關問題