InteractiveCU is a simple interactive create and update for AR.
Examples:
Create:
ruby-1.9.2-p180 :007 > User
=> User(id: integer, name: string, created_at: datetime, updated_at: datetime)
ruby-1.9.2-p180 :008 > User.interactive_create # or User.ic
==New User==
name: nash
SQL (0.8ms) INSERT INTO "users" ("created_at", "name", "updated_at") VALUES (?, ?, ?) [["created_at", Sun, 24 Jul 2011 08:49:26 UTC +00:00], ["name", "nash"], ["updated_at", Sun, 24 Jul 2011 08:49:26 UTC +00:00]]
=> true
Update:
ruby-1.9.2-p180 :009 > User.last.interactive_update # or User.last.iu
==Old User==
id: 8
name: nash
created_at: 2011-07-24 08:49:26 UTC
updated_at: 2011-07-24 08:49:26 UTC
==New User==
name: updated_nash
(0.5ms) UPDATE "users" SET "name" = 'updated_nash', "updated_at" = '2011-07-24 08:50:28.794082' WHERE "users"."id" = 8
=> true
It shows you validation errors:
ruby-1.9.2-p180 :010 > User.last.iu
==Old User==
id: 8
name: updated_nash
created_at: 2011-07-24 08:49:26 UTC
updated_at: 2011-07-24 08:50:28 UTC
==New User==
name:
Something went wrong:
name: <------ can't be blank
=> nil
This is pretty cool and handy