Elegant way to reverse order Formtastic nested objects?

Posted by stephan.com on Stack Overflow See other posts from Stack Overflow or by stephan.com
Published on 2010-12-28T07:49:58Z Indexed on 2010/12/28 7:53 UTC
Read the original article Hit count: 205

Filed under:
|

I'm presenting a list of items to the user with a field for a new item, like this:

- current_user.tasks.build
- semantic_form_for current_user do |f|
  - f.semantic_fields_for :tasks do |t|
    - t.inputs do
      = t.input :_destroy, :as => :boolean, :label => ''
      - if t.object.new_record?
        = t.input :name, :label => false
      - else
        = t.object.name

Which looks lovely and works like a charm. My only problem is I want the new record at the TOP of the list, not the bottom. Is there an elegant and easy way to do this, or am I going to have to do the new element separately, or loop through the list manually?

© Stack Overflow or respective owner

Related posts about nested-forms

Related posts about formtastic