This strategy can be used for creating / removing associations between two objects in a Rails app using Ajax / UJS. For example, setting up tag associations (i.e., one tag name applied to many individual posts) or favorites (i.e., many users saving personal favorites against global objects).
It's designed to work in a list / table format, where you're creating and removing associations in a single page format. To initiate, make sure the list / table partial for each "owner" item contains the content from _item-partial.html.erb
. A similar setup should also work in non-list / table formats, as long as each instance of the owner artifact includes the classes and data attributes required by the JavaScript partials.