Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
class-table-inheritance
Advanced tools
If you are using Rails 2.3.8 or other version < 3, you have to use the version 1.1.x of this gem. For Rails 3 you need to use the version 1.2.x or master of this gem. For Rails 4 and 5 you need to use the version 1.3.x to 1.4.x. For Rails 6 you need to use version 1.5.x or master of this gem.
This is an ActiveRecord plugin designed to allow simple multiple table (class) inheritance.
This plugin was inspired by: inherits_from plugin => http://github.com/rwl4/inherits_from and Multiple Table Inheritance with ActiveRecord => http://mediumexposure.com/multiple-table-inheritance-active-record/
gem install class-table-inheritance
create_table :products do |t|
t.string :description, :null => false
t.string :subtype # Only if you need access of both side see example
t.decimal :price
t.timestamps
end
create_table :books, :inherits => :product do |t|
t.string :author, :null => false
end
create_table :videos, :inherits => :product do |t|
t.string :year, :null => false
t.string :genre, :null => false
end
class Product < ActiveRecord::Base
acts_as_superclass # only if you want top-down access.
end
class Book < ActiveRecord::Base
inherits_from :product
end
class Video < ActiveRecord::Base
inherits_from :product
end
book = Book.find(1)
book.name => "Agile Development with Rails"
book.author => "Dave Thomas"
book.price => 19.00
video = Video.find(2)
video.name => "Inseption"
video.year => "2010"
video.genre => "SCI-FI"
video.price => 22.00
book = Book.new
book.name = "Hamlet"
book.author = "Shakespeare, William"
book.price => 14.00
book.save
create_table :mod_users do |t|
t.string :name, :null => false
end
create_table :managers, :inherits => 'Mod::User' do |t|
t.string :salary, :null => false
end
class Mod::User < ActiveRecord::Base
end
class Manager < ActiveRecord::Base
inherits_from 'Mod::User'
end
if you want to access product and get field in the subclass do you need to create a field subtype:string in superclass and ad acts_as_superclass in superclass and now you can do like this.
product = Product.find 1 # This is a Book instance.
product.author
product = Product.find 2 # This is a Video instance.
product.genre
if you need help contanct me: bfscordeiro (at) gmail.com .
Copyright (c) 2010 Bruno Cordeiro, released under the MIT license
FAQs
Unknown package
We found that class-table-inheritance demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.