0

我在时间表和时间表之间有一个accepts_nested_attributes_for 关联。这很好用,但是当我想输出时间表时,这些行会根据时间表记录的 ID 进行排序。相反,我想订购“daynr”字段上的行。我怎样才能做到这一点?代码是这样的:

<% for timesheetline in timesheet.tms_timesheetlines %>
  <%= timesheetline.daynr %>
  <%= timesheetline.description %>
<% end %>
4

1 回答 1

0

尝试:

<% for timesheetline in timesheet.tms_timesheetlines.order(:daynr) %>
于 2012-04-11T07:40:12.937 回答