Hello,
I am brand new to RoR trying to use the framework to build a simple
web application (for an imaginary online shop) just to learn the
ropes. Once every so often I come upon some problem that seems to have
a really simple solution but I just cannot see it because of my
inexperience. I was hoping you could help me out…
So here’s the issue. I have a simple mySQL database and a scaffold
model for it. The database will contain products with a name and two
different prices (eg. per unit and per kg). However the products
themselves have 5 different price type combinations (each, unit, kg,
100g, 100ml). Each product has to have at least 2 out of the 5 prices,
but I will be importing them directly and I I have no control of which
2.
I am trying to set up the validation for this, but I have no idea how.
It needs to check that at least 2 of the 5 prices are present, but it
does not matter which. The railes validates_ methods seem a bit simple
for this, but maybe I’m just not seeing it. When the controller
invokes the create method is there any way to use the params passed in
the validation? If not then any idea how I can solve this problem?
Thanks for any and all help,
W