Ruby on Rails
at TECH
158:デフォルトの名無しさん
07/11/20 07:54:16
>>157
自前で並べ直すしかないんじゃないかな。
hash = {}
Model.find(ids).each {|model| hash[model.id] = model}
models = ids.collect {|id| hash[id]}
puts models
または
hash = {}
ids.each_with_index {|id,index| hash[id] = index}
models = []
Model.find(ids).each {|model| models[hash[model.id]] = model}
puts models
次ページ続きを表示1を表示最新レス表示スレッドの検索類似スレ一覧話題のニュースおまかせリスト▼オプションを表示暇つぶし2ch
4331日前に更新/240 KB
担当:undef