Skip to content

Instantly share code, notes, and snippets.

@timblair
Last active December 14, 2015 04:39
Show Gist options
  • Save timblair/5029591 to your computer and use it in GitHub Desktop.
Save timblair/5029591 to your computer and use it in GitHub Desktop.
cd /tmp
brew update
brew upgrade ruby-build
rbenv install 2.0.0-p0
rbenv shell 2.0.0-p0
curl -fsSL curl.haxx.se/ca/cacert.pem -o "$(ruby -ropenssl -e 'puts OpenSSL::X509::DEFAULT_CERT_FILE')"
gem install bundler --pre # Successfully installed bundler-1.3.0.pre.8
gem install rails # Successfully installed rails-3.2.12
rails new test-app
cd test-app
curl -s https://gist.github.com/timblair/5029591/raw/2-tableless.rb -o app/models/tableless.rb
# From http://stackoverflow.com/a/938786/207828
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
# bundle exec rails console
Loading development environment (Rails 3.2.12)
>> Tableless.new.dup
NoMethodError: private method `initialize_dup' called for #<Tableless >
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment