Activerecord default accessors & unusual requirements

Posted by JP on Stack Overflow See other posts from Stack Overflow or by JP
Published on 2010-04-15T22:39:11Z Indexed on 2010/04/15 22:43 UTC
Read the original article Hit count: 145

Filed under:
|

I have an ActiveRecord::Base class which needs to have a field that is automatically generated when a new instance is made. How should I go about doing this? By defining an initialize function?

class Thing < ActiveRecord::Base
  # 'special' (integer) needs to be set to lowest unused number (above 0)
  # considering that random rows will be removed via other processes
end

This is as far as I've got! Any ideas?

© Stack Overflow or respective owner

Related posts about ruby

Related posts about activerecord