RubyFlow : The Ruby Community Blog

Home   Submit   Sign Up   Log In   leaders   Twitter   RSS Feed  

A cleaner alternative to accepts_nested_attributes_for

Redtape provides an alternative to ActiveRecord::NestedAttributes#accepts_nested_attributes_for in the form of, well, a Form! The initial implementation was heavily inspired by "7 Ways to Decompose Fat Activerecord Models" by Bryan Helmkamp.


Really like the look of this. It is similar to something I have been thinking about for a while. Could this object do more than just assist in nested objects? A few thoughts:

Would love for it to have a default implementation of populate for simple non-nested objects. This would just create an instance of the object being saved/validated and assign each accessor. Kind of an alternative to attr_protected or the new strong attributes.

Would be nice if validation could also be placed at this form level. This way validations at the object level could apply site-wide, but you could layer additional validation on a per-form basis. Would be nice for multi-page forms or having stricter requirements in certain setups (maybe admin screens have less validation than end user screens).eric - November 06, 2012 23:05
Eric: I've considered this. My concern is that, quickly, redtape begins to overlap with other gems such as Inherited Resources.

I didn't document it but validations can be placed in the form. However, I'd strenuously recommend against using them for anything but fields that do not map directly onto a model's field. Otherwise, the form validation begins to overlap responsibilities with the model's validations.

Good thoughts, though. I've barked up similar trees already.elight - November 07, 2012 15:14
When it became clear Coach Factory Online about midnight that President Barack Obama was safely on Louis Vuitton Belt the way to re-election, a handful of cranky and Coach Outlet Store inebriated Republican donors wandered about Gucci Belt Romney's election night headquarters, angrily demanding that the Coach Factory Outlet Online giant television screens inside the ballroom be switched from CNN Coach Factory Store to Fox News, where Republican strategist Karl Rove was Coach Factory Online making frantic, face-saving pronouncements about Coach Factory Outlet how Ohio was not yet lost.But the signs of Coach Outlet Online desperation inside the Boston Convention and Coach Bags Outlet Exhibition Center on Tuesday night were symptomatic of a Republican Party Coach Factory Online now standing at a crossroads, with not much track in sight.Romney lost Coach Factory Outlet Online embarrassingly among young people, African-Americans and Hispanics, a brutal Coach Outlet Online reminder for Republicans that their party is ideologically out of tune with Coach Factory Outlet fast-growing segments of the population.Obama crushed Romney among Hispanic Hermes Belt voters by a whopping 44 points, a margin of victory that Coach Factory Online likely propelled the president to victories in Nevada, Colorado and possibly Florida.yaya - November 09, 2012 01:24

Post a Comment

Comment abilities for non registered users are currently deactivated, pending time to add a proper CAPTCHA to solve the escalating spam problem. Sorry!