Skip to content

Instantly share code, notes, and snippets.

@teaforthecat
Created February 13, 2013 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save teaforthecat/4945889 to your computer and use it in GitHub Desktop.
Save teaforthecat/4945889 to your computer and use it in GitHub Desktop.
This is an example of a field set using the nested_form gem along with the twitter bootstrap style framework. It enables very efficient editing of data and relationships since three objects can be edited at once. Instead of being directed to another form and having to go back, ajax is used to create a dynamic form.
%li.reference_group
.container-fluid
.row-fluid
.span1.move
%i.icon-move
.span4
= f.input_field :label_markdown, placeholder: '<markdown enabled>'
= f.input :order, as: :hidden
.span7
= f.link_to_remove class: 'btn btn-danger' do
%i.icon-minus-sign.icon-white
.row-fluid.references_container
.span12
= f.link_to_add :references, class: 'btn' do
%i.icon-plus
Add Reference
%ul.sortable.references
= f.fields_for :references do |ff|
%li.reference
.row-fluid
.span1.move
%i.icon-move
.span11
= render "admin/reference_fields", f: ff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment