single-table-inheritance

Polymorphic associations on potentially unlimited types

Polymorphic associations on potentially unlimited types
Ok so here is my situation. Im a PHP developer recently turned Rails developer. In PHP code the use of abstract classes as "base" classes is a pretty common pattern. When moving onto my current Rails application I did a lot of the "pre-plan

Struggling with complex Rails activerecord associations and join models [closed]

Struggling with complex Rails activerecord associations and join models [closed]
I am fairly new to Rails and I would really appreciate some pointers in the right direction. I understand the pros and cons of STI.What would be the best practices for modeling AR-relations with a combination of Single table inheritance and polymorph

ActiveRecord single table inheritance - how to get root model?

ActiveRecord single table inheritance - how to get root model?
I have a model using single table inheritance and a concern that should work on any model.Consider this example:class Car acts_as_categorizable end class Suv < Car; end module Categorizable def after_safe siblings = this.class.where(category: self.ca

Aggregation in Single Table Inheritance in Ruby on Rails

Aggregation in Single Table Inheritance in Ruby on Rails
I'm working on Single Table Inheritance in Rails followingthis guide. The classes that I'm working with are as follows:Superclass:ArticlesSubclass:Tutorials, Projects, ThoughtsAll of them contain 'Comments'So I'm able to display all of these articles

Ruby on Rails Single Table Inheritance (STI) and unit test problem (with PostgreSQL)

Ruby on Rails Single Table Inheritance (STI) and unit test problem (with PostgreSQL)
I'm using an STI model with a single "Accounts" table to hold information for Users and Technicians (i.e. User < Account, Technician < Account). Everything works from a functional perspective, but things explode when running unit tests:...

Multiple Table Inheritance vs. Single Table Inheritance in Ruby on Rails

Multiple Table Inheritance vs. Single Table Inheritance in Ruby on Rails
I have been struggling for the past few hours thinking about which route I should go. I have a Notification model. Up until now I have used a notification_type column to manage the types but I think it will be better to create separate classes for th

Multiple Devise models with unique attributes

Multiple Devise models with unique attributes
Short explanation:I seek architectural advice and help in implementing multiple Devise models in a single app.More detailed explanation:My application needs to perform the following behavior:There are 3 types of users (Partner,Attendee,Speaker) which

Is it possible to create a conditional association in model?

Is it possible to create a conditional association in model?
I have setup a role based access controll system with the following models:Role (as STI),UserRole (global roles)ProjectRole (project specific roles)Assignment (Polymorphic with different resources)UserProject (as one resource type for assignments)Use
What Others Are Reading