Is there explicit support for Single Table Inheritance in Django? Last I heard, the feature was still under development and debate.
Are there libraries/hacks I can use in the meantime to capture the basic behavior? I have a hierarchy that mixes different objects. The canonical example of a corporation structure with an Employee class, ...
Given a model
class BaseModel < ActiveRecord::Base
validates_presence_of :parent_id
before_save :frobnicate_widgets
end
and a derived model (the underlying database table has a type field - this is simple rails STI)
class DerivedModel < BaseModel
end
DerivedModel will in good OO fashion inherit all the behaviour from BaseModel,...
I have a Rails app that uses STI to handle different types of Users, such as:
class Admin < User
...
end
I want to use memcached, but I keep getting the dreaded "unknown class/module" error. I've tried pre-loading all of my ActiveRecord models to no avail. The first request works as normal, but the first pull from memcached errors o...
Why can't I define a member with the same name in subclasses? I have a one table per class inheritance with a rowversion timestamp field in each table. It seems like the Entity designer should allow for this and use the new keyword on the property to make it happen. What is the workaround? How can I specify the same field in an inher...
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:
...
8) Error:
test_the_truth(UserTest):
ActiveRecord::StatementInvalid: PGError: ERROR: relation "t...
For context, we are storing most of our data as JSON strings. This works very well with Hadoop on the backend and is easy to handle in Ruby on the front end. My data types fit the natural pattern for inheritance.
For simplicity, lets say I have a class Pet and a process FeedPet that feeds a pet. I also have a process WalkDog that only a...
Hi,
In my Rails App I've several models dealing with assets (attachments, pictures, logos etc.). I'm using attachment_fu and so far I have 3 different tables for storing the information in my MySQL DB.
I'm wondering if it makes a difference in the performance if I used STI and put all the information in just 1 table, using a type colum...
Hello, I have a has_many relationship between two entities, Feeds and Posts. I also have specific types of posts, Videos and Photos. This is structured in the database using single table inheritance.
Right now I have my Feed model specifying a has_many relationship between Feeds and Posts (including the subtypes)
class Feed < ActiveRec...
For single table inheritance, how do you force Rails to use an integer column for the 'type' column instead of string?
...
When using single table inheritance does one have to be careful not to populate the columns which are specific to different models? Is there a way to specify which columns each model uses?
...
I am having an issue with searching for records in my STI table due to my inheritance structure
class User < ActiveRecord::Base
class LegacyUser < User
class AuthUser < User
class SuperUser < AuthUser
class FieldUser < AuthUser
class ClientAdmin < AuthUser
The problem is that find does not work for the AuthUser Model. The...
I am using Single Table Inheritance for managing different types of projects.
I decided to store some information associated with each project type. So i created new table "project_types" with "model_type" field as primary key. Primary key values are values of "type" field of "projects" table. Problem: When i trying to get associated wit...
I'm using single table inheritance for my application. My polymorphic type is Maintenance with only one subtype, right now, named OilChange. I'm running into problems creating my records in my create method in the controller. Here's the code.
@log = Log.new(params[:log])
@log.maintenance = Maintenance.new(params[:maintenance])
The ...
Im trying set the single table inheritance model type in a form. So i have a select menu for attribute :type and the values are the names of the STI subclasses. The problem is the error log keeps printing:
WARNING: Can't mass-assign these protected attributes: type
So i added "attr_accessible :type" to the model:
class ContentItem...
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 the types of notifications as they behave differently.
Right now, there are 3 ways notifi...
Hi,
i have following code
class Category < ActiveRecord::Base
has_many :categorizations
has_many :posts, :through => :categorizations
end
class Post < ActiveRecord::Base
has_many :categorizations
has_many :categories, :through => :categorizations
end
class Categorization < ActiveRecord::Base
belongs_to :post
belongs_to :ca...
I am currently building a rails application based around insurance. There is an admin section where the staff can control the system tables, mostly what appears in drop down lists, although some are more complex with their own associations. The main model in this application is the policy, this needs to hold/link to information in many o...
Our organization is looking to standardize on Entity Framework once v4 comes out. As a result, I am looking at what it would take to migrate our application that uses NHibernate for persistence to EF4 using POCO support. In a couple of places we use single table inheritance (also known as Table Per Hierarchy). I have been unable to get i...
Hi,
I have the following two models
class ContactField < ActiveRecord::Base
end
class Address < ContactField
end
class Phone < ContactField
end
and
class Contact < ActiveRecord::Base
end
class Company < Contact
end
class Person < Contact
end
I want one contact, no matter is it Company or Person, to have many ContactFields(Addre...
In Castle Activerecord (on top of NHibernate), is it possible to use class table inheritance globally, and single table inheritance on part of the inheritance tree? I would like to do something like
/// <summary>
/// Base class for models
/// </summary>
[ActiveRecord("model"), JoinedBase]
public abstract class Model: ActiveRecordBase
{
...