Skip to content

Instantly share code, notes, and snippets.

@ColinDKelley
Created June 13, 2012 22:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ColinDKelley/2927004 to your computer and use it in GitHub Desktop.
Save ColinDKelley/2927004 to your computer and use it in GitHub Desktop.
Hobo example
class User < ActiveRecord::Base
fields do
first_name :string, :ruby_default => 'First'
last_name :string :ruby_default => 'Last', :null => false, :default => ''
name_addr :string, :ruby_default => lambda { "#{full_name} <#{email}>" }
email :string :ruby_default => lambda { organization.default_email }
level :enum, :limit => [:Basic, :Admin, :Super], :default => :Basic, :null => false
end
def full_name
[first_name, middle_name, last_name].select { |name| !name.blank? } * ' '
end
belongs_to :organization
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment