Rails 3 - Product Table Layout
I'm currently developing an app for selling tickets to an event. I'm in need of an efficient way of selling specific seats for the event but would prefer not to use a table row for each seat available. I also need to be able to lock 开发者_如何转开发specific seat (for a specified period of time) when someone has chosen a seat but not yet purchased it (so someone else can't buy it before them).
Would i need to create a row for each seat available or is there a more efficient way to go about this while still including the locking functionality.
I'm new to ruby/rails but not programming, any suggestions would be appreciated.
You could use the ActiveRecord's serialize
method to store e.g. a seat row instead of a single seat and then serialize the seats within the row. This approach makes things harder to maintain, though and will most likely cause you some other issues down the road, while saving you just a few requests.
All in all I'd probably go with a row per seat. Maybe use a parent model like a seat row or a section to make things easier. But that really depends on your case.
精彩评论