ActiveForm plugin
Published at: 24.IX.2007 21:49 CET
Last week at RailsConf Europe I met some people who are using my ActiveForm code to make forms in their Rails sites. It’s about time to wrap it up as a plugin, so here it is.
From the README:This plugin provides a base class for making forms with ActiveRecord validations without having a corresponding database table. You can use ActiveForm for:Installation:
- making forms which don’t needed storage, like simple email forms
- provide extra validations on existing ActiveRecord models
- make forms for composite objects
script/plugin install http://svn.remvee.net/plugins/active_form
I know, there already is a plugin called active_form but I don’t like it. It doesn’t provide a “real” AR object causing all kinds of things to not work (like ActiveRecordHelper#form and DateHelper#datetime_select for instance), it doesn’t include any tests and my version is a lot simpler (flog score 20 versus 74).
Why not change the name? I like it! If you can come up with something better, please leave a comment.
Probably just being pedantic here, but I noticed your active form plugin is based upon ‘columns’ whereas this doesn’t seem correct to me if one is not talking about tabular data.
Why didn’t you go for the (IMHO) more obivious ‘fields’ solution?
The
columnmethod actually adds columns to the object. Changing the method name tofieldmeans I should provide aliases to all column related methods likecolumn_namesandcolumns_hash.Note, it still is an ActiveRecord object! It has a database connection, the save method is protected by an transaction and other goodies are still in place.