What’s the best way to create a model in Ruby on Rails that doesn’t have an underlying implementation in as far as a database table goes? It’s very common to write classes that perform behavior on a particular problem domain, yet can use some of the benefits that ActiveRecord has such as validation.
Is it best to just create it as a module or helper? What is the best practice here?
Checkout the screencast by Ryan Bates that covers exactly this – Tableless Models.
http://railscasts.com/episodes/193-tableless-model
With this approach, your Model would still subclass
ActiveRecord::Basebut define the columns manually, which allows you to useActiveRecordfeatures such as validations, and associations without a database.