From: Jesse Crockett Date: 2008-09-22T02:42:52+09:00 Subject: comparison of Array with Array failed I am passing this hash to a method to sort it, which works in irb but in rails I can't get past it report = { :cals => @total_cals, :fat => @dv_fat, :sfat => @dv_sfat, :carbs => @dv_carbs, :chol => @dv_chol, :sodium => @dv_sodium, :protein => @dv_protein, :fiber => @dv_fiber, :calcium => @dv_calcium, :copper => @dv_copper, :folid_acid => @dv_folid_acid, :iron => @dv_iron, :magnesium => @dv_magnesium, :iron => @dv_iron, :pantothenic_acid => @dv_pantothenic_acid, :phosphorus => @dv_phosphorus, :riboflavin => @dv_riboflavin, :thiamin => @dv_thiamin, :a_iu => @dv_a_iu, :b6 => @dv_b6, :b12 => @dv_b12, :c => @dv_c, :d => @dv_d, :e => @dv_e, :zinc => @dv_zinc, :potassium => @dv_potassium } Here is the method giving me trouble def overview_text(report_hash) array_sorted = report_hash.sort { |a,b| a[1] <=> b[1] }.reverse rich = very_plentiful = plentiful = good_source = small_amount = minimal_amount = Array.new @a = 0 until @a == array_sorted.length if array_sorted[@a].last > 35 && (array_sorted[@a][0] == :fat or array_sorted[@a][0] == :carbs or array_sorted[@a][0] == :protein or array_sorted[@a][0] == :fiber or array_sorted[@a][0] == :chol) rich << array_sorted[@a].first.to_s elsif array_sorted[@a].last > 35 && (array_sorted[@a][0] != :fat or array_sorted[@a][0] != :carbs or array_sorted[@a][0] != :protein or array_sorted[@a][0] != :fiber or array_sorted[@a][0] != :chol) very_plentiful << array_sorted[@a].first.to_s elsif array_sorted[@a].last <= 35 && array_sorted[@a].last > 20 plentiful << array_sorted[@a].first.to_s elsif array_sorted[@a].last <= 20 && array_sorted[@a].last > 8 good_source << array_sorted[@a].first.to_s elsif array_sorted[@a].last <= 8 && array_sorted[@a].last > 2 small_amount << array_sorted[@a].first.to_s elsif array_sorted[@a].last <= 2 && array_sorted[@a].last > 0 minimal_amount << array_sorted[@a].first.to_s end @a += 1 end output = "Rich in #{rich.to_sentence}, ", "Very Plentiful in #{very_plentiful.to_sentence}, ", "Plentiful of #{plentiful.to_sentence}, ", "a Good Source of #{good_source.to_sentence}, ", "with Small Amounts of #{small_amount.to_sentence}, ", "and Very Low in #{minimal_amount.to_sentence}." . . . end -- Posted via http://www.ruby-forum.com/.