所以我有三种模式-预订,天棚,商务用户预订属于天棚,天棚属于businessuser,businessuser有许多天棚。
我正试图在我的应用程序助手中创建一个find/where子句,该子句将只返回大于当前日期且属于预订的选框(即预订具有其id)。
我现在能显示的是有天棚的预订但我想让它显示已预订的天棚。
这是我在应用程序帮助程序中使用的方法

 def upcomingbookings
   @bookings = Booking.all
   @futuremarquees = Booking.where("marquee_id")
 end

预订的字段为:StartDateTime与Date.Today比较。
只是为了澄清商业逻辑:天棚是一个帐篷,人们可以预订他们的党。所以系统里有很多帐篷。当有人预订时,它会存储天棚id。预订有自己的变量,如startdatetime和eventtype我正在创建一个页面,当一个业务用户登录时,他们可以查看他们添加到系统中的当前有预订的所有选框

最佳答案

您可以执行以下操作:

# returns Marquee records having at least one booking in the future
marquees = Marquee.includes(:booking).where('bookings.startdatetime > ?', Date.today)

如果您想找到属于特定Marquee的未来Booking
marquees = Marquee.includes(:booking).where('bookings.startdatetime > ?', Date.today)
marquees = marquees.where(booking: { id: params[:booking_id] })

关于ruby-on-rails - 如何显示将来预订的产品?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29749545/

10-13 03:22