Design question

Hi,

I am really enjoying the experience of writing my first web app in
Rails. I particularly like the instant feedback the framework offers
when developing in small increments and I am learning new things all the
time. However since I develop alone and my inexperience with rails Iâ??m
asking for help to answer some design questions that I have regarding my
first app.

After reading the Agile Rails Dev book I have implemented a shopping
cart system for a fictional holiday property rentals site (may develop
into something more in future) with a few modifications. Instead of
adding line_items it adds available dates for the rental of a particular
property details of which are held in a rentals table which is updated
when as user checks out.

This is fine as long as there is validation against the rentals table
for available dates before adding them to the cart and validation for
duplication of dates already in the cart. The problem is, what happens
when two users add identical properties and dates to their carts at the
same time. If one of them checks out and makes a booking, what happens
to the other user and their cart item? Is it a case of better luck next
time â??you should have checked out quickerâ?, or is it a design and
usability issue.

Would it not be better to test all current sessions for availability of
desired property and dates and then allow users to add chosen dates to
cart if available. The trouble is, is that Iâ??m not sure how to do this
or if it is the right solution at all for this problem.

Any ideas on this issue or where I can find answers to design problems
of this nature are greatly appreciated thanks.

As soon as a user picks out a date, I would mark that date somewhere in
your database as “hold”. I would then not allow anyone else to pick
that date for 20 minutes, This would give the user plenty of time to go
through your checkout. Once the 20 minutes has passed I would disregard
the hold status. You could then write script/runner that would clear
out your table each night of dates that were on hold but never “checked
out”.

On Thu, 2006-05-25 at 15:02 +0200, casper stevens wrote:

when two users add identical properties and dates to their carts at the
Any ideas on this issue or where I can find answers to design problems
of this nature are greatly appreciated thanks.

Charlie B.
http://www.recentrambles.com

Charlie B. wrote:

As soon as a user picks out a date, I would mark that date somewhere in
your database as “hold”. I would then not allow anyone else to pick
that date for 20 minutes, This would give the user plenty of time to go
through your checkout. Once the 20 minutes has passed I would disregard
the hold status.

This sounds like a good idea. Just one question, currently dates are
entered in the rentals table only when the user checks out only and is
searched every time a user chooses a pair of dates.

Your idea suggests that avaliable date pairs added to a cart session are
also added to the rentals table if, a hold flag set to true and a
timestamp to calculate the time lapsed. If the user checks out in time -
the hold flag is kept at true and a booked flag is set to true.

How does this correspond to the time-to-live of the session since the
hold flag could expire before the session holding the rental item,
leaving the app in an inconsistent state.

Could there be duplication here. Is a session based cart useful /
beneficial in this situation.

You could then write script/runner that would clear

out your table each night of dates that were on hold but never “checked
out”.

On Thu, 2006-05-25 at 15:02 +0200, casper stevens wrote:

when two users add identical properties and dates to their carts at the
Any ideas on this issue or where I can find answers to design problems
of this nature are greatly appreciated thanks.

Charlie B.
http://www.recentrambles.com