active_record-tableless_model

Simplify creating ActiveRecord clases which don’t need a database table. Useful for:

  • Factory method, ie creating other classes

  • Wizard (multi-step) forms

  • Presenter style forms handling mutiple models

Thanks to Ryan Bates Tableless Model Railscast and the {Tableless Model asciicast}[asciicasts.com/episodes/193-tableless-model.html for the inspiration] .

There is an active_record-tableless_model introduction on Keith McDonnells ruby blog .

Install

@$ gem install active_record-tableless_model@

Usage

require 'active_record-tableless_model'

class Task < ActiveRecord::Base
  no_table 

  column :description,  :text
  column :priority,     :integer
  column :project_id,   :string  
end

Note that your class must still inherit from ActiveRecord if you need to use validations and associations.

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.

Copyright © 2011 Keith Mc Donnell . See LICENSE for details.