Hi all !
I’m currently developing a game using Ruby On Rails and have a
question on how to design my controller, given the following concept:
There are the following models: Product, Offer, Storage, User (and
others, of course). Users can create offers for their products and of
course, they can buy them. A Offer is associated with ONE product, so
if you create 5 offers, there will be 5 INSERT statements.
Example: A User creates an Offer for beer (a Product), he produced and
he sees something like this: http://bayimg.com/dAkaKAAbh So he selects
an amount, and in the create action I’m doing something like
If the User selects 6 as amount, there will be 6 different Offers in
the database, each linked to another product.
When I list the offers for buying, I want to provide this interface:
http://bayimg.com/DakAjaaBH. Now there’s a problem (from my point of
view). If (another) User selects 3 as amount of beer to buy, how can I
fetch the right Offers from the database ?
I’m actually doing something like providing a “master” offer_id to the
buy-action and fetching an offer. Then I know about the product and
fetch all offers with the same product-“types” like the first offers.
I hope there’s anyone who understands what I’ve written. My question
is, does anyone knows a better idea how to handle this. This is surely
not a everyday problem, but I hope your guys are creative^^.
If you have any questions, cause you didn’t understand me, I will
answer them ! Thank you very much in advance.