我正在嘗試使用formtastic來呈現嵌套窗體。我有has_many/accep_nested_attributes_for安裝在我的父母模型。一切都很好。唯一的問題是我想排序嵌套模型的順序。排序accept_nested_attributes_for in formtastic
# this works but i want answers sorted a certain way
= semantic_form_for survey do |f|
= f.inputs :for => :answers do |answer_form|
= answer_form.input :content
,如果我嘗試做這樣的事情:
# form styles become extremely messed up but the order is correct
= semantic_form_for survey, do |f|
= f.semantic_fields_for :answers, f.object.answers.joins(:question).order('questions.position') do |answer_form|
= answer_form.input :content
我甚至嘗試創建一個名爲「假」的has_many關係:使用sorted_answers:finder_sql和:類,但不工作,要麼( answer_form是無IIRC)。
我想我問的是如果我可以使用:for =>(關係),但指定關係的順序。也許使用:for_options?