No commit activity in last 3 years
No release in over 3 years
Include ActiveRecord::Model in your model instead of inheriting from ActiveRecord::Base.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
>= 0

Runtime

~> 4.0.0
 Project Readme

Includable::ActiveRecord

Build ActiveRecord models via module inclusion instead of class inheritance.

Since you're only allowed to inherit from a single class, it would be preferable to include ActiveRecord as a module. This allows class inheritance to be used for cases where there's an actually hierarchical relationship.

This gem creates a module named ActiveRecord::Model that includes all the same functionality as ActiveRecord::Base, including everything that has been mixed into ActiveRecord::Base.

Usage

In your model, just include ActiveRecord::Model:

class User
  include ActiveRecord::Model
  # ...
end

This is effectively equivalent to:

class User < ActiveRecord::Base
  # ...
end

Installation

Add this line to your application's Gemfile:

gem 'includable-activerecord'

And then execute:

$ bundle

TODO

  • Add some tests. This is pretty simple, but we should test a few things.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request