Ruby on Rails at TECH
[2ch|▼Menu]
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