Creating a page to edit many child objects with one submit--What JS Framework?

Any suggested best practice for creating a Rails UI to edit many child objects on one page?

A simple example would be putting in monthly stock returns for a portfolio of securities. The UI will allow editing the “return” values of stocks in the portfolio, and add another month’s worth of values easily. This would be tedious one record at a time.

There’s a related railscast on this topic: #165 Edit Multiple (revised) - RailsCasts

I’ve seen suggestions not to use accepts_nested_attributes_for and to possibly use form objects for this sort of task.

I’m wondering if I’ll simple end up with a lot of coffeescript & jQuery to make come out nicely.

Or if it’s useful to try to work EmberJs into an existing Rails app.

While I’ve used AngularJs a bit, I’d rather focus on EmberJs, if I was going to learn one.

(And if you search “rails 4 emberjs”, my tutorial is first on Google!)

Thanks for suggestions.

Have you checked out cocoon: GitHub - nathanvda/cocoon: Dynamic nested forms using jQuery made easy; works with formtastic, simple_form or default forms? Sounds like what you might be looking for.


Looks promising. There’s a demo here: GitHub - nathanvda/cocoon_simple_form_demo: a small Rails application demonstrating nested forms with cocoon and simple_form

I’ve seen some article references (such as to replacing “accepts_nested_attributes_for” with form objects. Wondering if anybody else has any opinions on accepts_nested_attributes_for.

I’m considering simply using accepts_nested_attributes_for without any fancy Javascript.

Here’s a sample from the cocoon demo.

class Project < ActiveRecord::Base
  has_many :tasks
  has_many :people
  belongs_to :owner, :class_name => 'Person'

  has_many :project_tags
  has_many :tags, :through => :project_tags, :class_name => 'Tag'

  accepts_nested_attributes_for :tasks, :reject_if => :all_blank, :allow_destroy => true
  accepts_nested_attributes_for :people, :reject_if => :all_blank, :allow_destroy => true
  accepts_nested_attributes_for :owner, :reject_if => :all_blank
  accepts_nested_attributes_for :tags
  accepts_nested_attributes_for :project_tags

We have some notes on form objects and accepts_nested_attributes here: Form Objects

Totally getting hooked on React. Check out this interesting discussion about React in the context of EmberJS:

Anybody else using react on this forum?

I dabbled with React a bit. It took a bit to get my head around some concepts like the difference between states and properties and JSX. What I enjoyed most about React was that it was easy to make ajaxy pages without having to go full blown backbone/ember/angular etc. while still being able to avoid the JQuery callback soup that is common with a lot of Rails applications.

You might also want to consider something like best_in_place, it’s probably the lowest hanging fruit when you want to make ajax-driven pages consisting of multiple resources.