Best way to crud 2d hash with ranges

I have a Product model (name:string, value:integer, quality:integer) and
different table for each product with percent’s. Real value of product
depend on the percent from the table, taked from value range and quality
range.

For example I have this table for first product (row => quality range,
cols => value range): [Attachment]


I want to make a method called @product.real_value_percent(value,
quality), that will check first in what range is price and then in what
range is quality and return percent.

My ideas:

Static table

Make a percent table with static cols named value1, value2, value3 etc.
and left nil in unused cells.

Pros: easy validation, easy to develop
Cons: unnecessary cols, limited cols

has_many through

class Percent
belongs_to :value
belongs_to :quality
end

class Value
has_many :qualities, :through => :percents
end

class Quality
has_many :values, :through => :percents
end

Pros: clean in db
Cons: hard validation, hard editing

2x has_many

Make a relation: Value -n:m- Quality -1:1- Percent. If you want to take
a percent -> find value range, find related qualities, check range and
at last - take a percent.


Those ideas are not so clean and simple - the biggest problem I have is
with editing this table values. In each solution it’s complicated and
not so clean.

Ranges are a problem too - I can make different cols in sql (from:float
to:float)
and check in sql with find - value > from and value < to. Second idea is
to store range in string for example 1…30 and convert this every time
to ruby range.

Is there a better way to do it all?
How to save ranges?
How to make editing, deleting and creating table for each product easy
and usable (like in spreadsheet)?
Are there any plugin’s to help doing it?

Thanks in advance.