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.
Attachments:
http://www.ruby-forum.com/attachment/5860/tabel.jpg
-- 
Posted via http://www.ruby-forum.com/.
-- 
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.