一時的に使う変数をモデルに持たせたいとき

モデルそのものを使うのではなくて、モデルをハッシュに変換して変数を追加する
model.attributesでモデルをハッシュに変換できるので、これを使った

配列にハッシュでモデルの全変数を入れている

array = Array.new
MyModel.all.each |m| do
    hoge = m.attributes
    hoge["temp_var"] = "store something"
    array.push hoge
end

http://stackoverflow.com/questions/4153747/is-there-some-ruby-on-rails-method-to-convert-a-model-object-into-a-hash-structu

これをこの一時変数でソートしたいような場合(temp_varが文字列の場合)

array.sort! { |a,b| a["temp_var"]downcase <=> b["temp_var"].downcase }

http://stackoverflow.com/questions/4610843/how-to-sort-an-array-of-objects-by-an-attribute-of-the-objects