app/models/tableless.rb
# http://stackoverflow.com/questions/937429/activerecordbase-without-table
# Models without Tables
class Tableless < ApplicationRecord
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