2012-04-11 5 views
0

私は、タイムシートとタイムシートの間にaccepts_nested_attributes_forの関連付けを持っています。これはうまくいきますが、タイムシートの出力をしたいときは、タイムシートのレコードのIDでその行が順序付けられます。代わりに、 "daynr"フィールドに行を並べ替える必要があります。どうすればこれを達成できますか?コードは次のようである:accepts_nested_attributes_for lines

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

答えて

0

試してみてください。

<% for timesheetline in timesheet.tms_timesheetlines.order(:daynr) %> 
関連する問題