Skip to content

Instantly share code, notes, and snippets.

@potomak
Created August 19, 2010 08:25
Show Gist options
  • Save potomak/537390 to your computer and use it in GitHub Desktop.
Save potomak/537390 to your computer and use it in GitHub Desktop.
class Contact < Tableless
column :email, :string
column :message, :text
validates_presence_of :email, :message
end
class Tableless < ActiveRecord::Base
def self.columns()
@columns ||= []
end
def self.column(name, sql_type = nil, default = nil, null = true)
columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null)
end
# override the save method to prevent exceptions.
def save(validate = true)
validate ? valid? : true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment