I am developing a very simple "auctions" rails (v3.0.5) app for educational purposes. I have some scaffolding for products and users. Products have the following attributes: Name, Status, Price, Price_increment, Start_datetime, end_datetime, Time_ increment, Last_bidder , Auction_winner (also Id and timestamps). Users have the following attributes: Name, Times _bid (Id + timestamps).
The idea is the following:
- At first, the each product has the status set to "Inactive". Automatically, it must be set to "Active" at the start_datetime.
- In the products page, where all the products are listed, there should be a countdown in the format HH:MM:SS for every "Active" product in a column named "Remaining Time" (for all the other products, blank), instead of displaying the atributes start_datetime and end_datetime.
- Every "Active" product must have a link called "BID", and when the user clicks it the product's end_datetime must be increased by its Time_increment (that is in seconds), price should be increased by it's price_increment, and last_bidder must be set to the user's Id (since there is no authentication, it should always be the user with id "1").
- Every time a user makes a bid, the bid counter "Times_bid" must be increased by one.
- When the "Remaining Time" gets to 0 (when the actual time = end_datetime), Auction_winner must be set equal to last_bidder (if any) and the status to "Sold", if no user made any Bid (if last_bidder = 0), then the status must be set to ("Not Sold"), and the BID link must become inactive (as is it was only <p>BID</p>)
All of this MUST be Asynchronously updated in the products page.
I'll provide the files with the app containing the users and products scaffolding.