Rails 3 - 产品表布局
我目前正在开发一个用于销售活动门票的应用程序。我需要一种有效的方式来销售活动的特定座位,但不希望为每个可用座位使用一排桌子。当有人选择了座位但尚未购买时,我还需要能够锁定特定座位(在指定的时间内)(这样其他人就无法在他们之前购买)。
我是否需要为每个可用座位创建一排,或者是否有更有效的方法来解决这个问题,同时仍然包括锁定功能。
我是 ruby/rails 的新手,但不是编程,任何建议将不胜感激。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 ActiveRecord 的
serialize
方法来存储例如排座位而不是单个座位,然后对排内的座位进行序列化。不过,这种方法使维护变得更加困难,并且很可能会在以后给您带来一些其他问题,同时只为您节省了一些请求。总而言之,我可能会选择每个座位一排。也许可以使用父模型(例如座椅排或座椅部分)来使事情变得更容易。但这确实取决于您的情况。
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.