This is an age-old question where given a table with attributes \'type\', \'variety\' and \'price\', that you fetch the record with the minimum price for each type there is.
Table.minimum(:price, :group => :type)
See http://api.rubyonrails.org/classes/ActiveRecord/Calculations.html#method-i-minimum for more.