Ruby on Rails: Fully functional tableless model
问题 After searching for a tableless model example I came across this code which seems to be the general consensus on how to create one. class Item < ActiveRecord::Base class_inheritable_accessor :columns self.columns = [] 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 def all return [] end column :recommendable_type, :string #Other columns, validations and relations etc... end