Social Welfare

Social Welfare Overview
Social Welfare is a Rails plugin that makes it dead simple to update children objects from within their parents.The plugin has been streamlined so that you don’t have to write much code to derive the benefits of using the plugin. If you are familiar with the SubList rails plugin then you will understand what this plugin is attempting to achieve.
The problem with Rails is that it is hard to build interfaces that facilitate edits of multiple related items. Say for instance you have a shopping list and you want to modify the description of each item in the list. To do so with a scaffolded version of rails you would have to visit the edit URL of each item in the list! AJAX goes part of the way to solve this problem using in-place editing and so on, but ultimately this system falls short in situations like those that require atomic transactions.
What You Get

Social Welfare gives you the features highlighted in red in the large screenshot to the right:
- Update a child element
- Add a new child
- Remove an existing child
- Sort the children
- Clone a child
All user updates are made to the interface only and no data is transmitted to the server until the user submits the form. The screenshot to the right is taken while updating a parent, but the screenshot for creating a new parent would look almost identical (and same for the code).
Screencast
How To Install
From the root of your rails application:
ruby script/plugin install http://dev.alexpooley.com/social_welfare/tags/1.0.3 rm -rf vendor/plugins/social_welfare mv vendor/plugins/1.0.3 vendor/plugins/social_welfare
If you want to run the todo demo application then you will find it in the test directory of the plugin. You will need to run “rake db:migrate” to build the database. The demo assumes you have sqlite3 setup for Rails. If this is not the case, you will need to modify the database configuration of the demo application.
Coding For Social Welfare
Please consult the comprehensive Social Welfare rdoc documentation.
The plugin is entirely usable. However, you may find difficulties customizing the use of the plugin depending on how far you stray from the basic use case. Please contact me with any bug reports, patches, or feature requests and be sure to include a test case if possible.
Limitations, Requirements, and Caveats
- I have only tested this plugin in Rails 2.0 with Firefox and Safari on a Mac. Please send through confirmation that the plugin works with other browser/platform combinations.
- You must have prototype 1.6+ installed. The prototype.js file in public/javascripts of your rails root has version information at the top of the file.
- If you are placing your children in tables and sorting them, then you need to explicitly define a tbody within the table, otherwise sorting does not function correctly in Firefox.
- Validations are not really tested. They still work in the model, but reporting back the validation error to the user could be neater.
Why The Name?
The plugin helps parents render their children. Parents receive help from the plugin, and so they are able to subsidize their children.
Special Thanks
Thanks to railscast for publishing the complex forms series.
Special thanks go to Luke Galea for pointing me in the direction of the original railscast, and also for SubList. Unfortunately SubList has a fatal flaw that can produce conflicting ID’s. This is the reason why I started from scratch with Social Welfare.