I want tableless AR object. Pseudo code:
# tablefull AR object
class Item < ActiveRecord::Base
has_one :color
end
# tableless AR object, but persistant
class Color
include ActiveAttr::Model
belongs_to :item
attribute :color
Colors = [:yellow, :red, :black]
end
# expect
Color.first => #<Color id:1, color: :yellow>
Item.create(color: Color.first, foo: 'bar')
Item.where(color_id: Color.first)
I look at below so, but these are tableless and not persistant. How to create ActiveRecord tableless Model in Rails 3 Ruby on Rails: Fully functional tableless model