Forum: Ruby on Rails Default value plugin

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
90842970ceaf7ed19136ce7b6f8e1455?d=identicon&s=25 Michael Daines (Guest)
on 2006-06-06 04:42
(Received via mailing list)
I'm releasing a very small plugin that allows you to specify default
values for fields in models. Ordinarily, you might do this in your
schema, I guess, but then it's awkward if you need that on a
serialized field or need your default values calculated somehow.

So you can do something like this: (repeated from an earlier post and
the README)

   class Mixture < ActiveRecord::Base
     serialize :color
     default_value :color, [255, 0, 0]
   end

   m = Mixture.new
   m.color # => [255,0,0]

Here's the README:

   http://mdaines.com/svn/plugins/default_value/trunk/README

To install: (as usual)

   script/plugin install http://mdaines.com/svn/plugins/default_value/
trunk


Thoughts, comments?


--
Michael Daines
http://www.mdaines.com
6ef8cb7cd7cd58077f0b57e4fa49a969?d=identicon&s=25 Brian Hogan (Guest)
on 2006-06-07 12:20
(Received via mailing list)
I think that's actually pretty neat. I can think of a few uses for that
already.
This topic is locked and can not be replied to.