0

我的控制器有价值

@tour = Tour.find(:first, 
:conditions => ["beginDate in (?) AND tour LIKE ? AND duration + 1 = ? OR
                 beginDate in (?) AND tour LIKE ? AND duration + 1 = ?",
                 @day.day,  @day.travel.tour.name, @day.cruise.tour_days_count,
                 @day.day, 'Some Name', @day.cruise.tour_days_count])

他工作得很好。我怎样才能升级这段代码,让他更紧凑?
红宝石 1.8.7,轨道 2.3

4

2 回答 2

0
@tour = Tour.where("beginDate in (?) AND tour IN (?) AND (duration + 1) = ?", 
                    @day.day,  [@day.travel.tour.name, 'Some Name'], @day.cruise.tour_days_count])
       .first
于 2013-11-12T13:35:18.490 回答
0
@tour = Tour.find(:first, :conditions => ["beginDate in (?) AND tour IN (?) AND (duration + 1) = ?", 
  @day.day, [@day.travel.tour.name, 'Some Name'], @day.cruise.tour_days_count])
于 2013-11-12T14:37:16.840 回答