Questions tagged [sti]

Single Table Inheritance - a mechanism to add the principle of object-oriented inheritance onto relational database models by having child classes map onto the same table as their ancestors.

In Single Table Inheritance, types are discriminated by a field in the table that indicates what class in the hierarchy the object belongs to.

For more information see:

Single Table Inheritance - Martin Fowler - Patterns of Enterprise Application Architecture

384 questions
0
votes
1 answer

A polymorphic object that belongs to a quasi-STI object: object_type is incorrect

Consider: class Person < ActiveRecord::Base class << self def setup has_one :address, :as => :addressable end end end class Employee < Person setup end class Address < ActiveRecord::Base belongs_to :addressable, :polymorphic…
Ivan
  • 97,549
  • 17
  • 50
  • 58
0
votes
1 answer

ElasticSearch with Tire doesn't include custom analyzer with STI model

I have an STI model which I want to be searchable with ElasticSearch and Tire. The issue I am having is when Tire creates the mappings it seems to ignore my custom analyzers for the second model. Below is an example of my models. class Account <…
0
votes
3 answers

ActiveRecord won't build the right class using STI

I'm using single table inheritance in my application and running into problems building inherited users from an ancestor. For instance, with the following setup: class School < ActiveRecord::Base has_many :users end class User <…
Noz
  • 6,216
  • 3
  • 47
  • 82
0
votes
1 answer

Rails STI: implementing child class edit form

There is a lot of discussion around Rails 3 STI and how to use forms, but no definitive answers on StackOverflow. I seem to have run into a similar issue and have attempted the other solutions with no results. I have two models with the following…
mztwo
  • 365
  • 3
  • 18
0
votes
1 answer

validation error on update_attributes of a subclass (STI)

I implemented a signin/out machinery as Michael Hartl suggested in his tutorial (http://ruby.railstutorial.org/chapters/sign-in-sign-out). All worked perfectly: creating, deleting, updating user from a profile page. Then I created a Teacher model as…
fabbrro
  • 125
  • 7
0
votes
2 answers

Query by an associated model's subclass in rails

I have used Single Table Inheritance (STI) to create some Models with subclassed from a common parent. A separate model has an association with the superclass. Eg: as follows... class Fruit < ActiveRecord::Base has_many :smoothies end class Apple…
Felix
  • 674
  • 5
  • 16
0
votes
1 answer

SearchLogic + STI

Trying to implement a search logic search that uses associations with STI but I’m having a problem where it is not select the STI records as the subclass but the parent. Example: class Users end class Artist < User has many :agents, :through =>…
Gordon Isnor
  • 2,065
  • 1
  • 19
  • 32
0
votes
1 answer

Rails: should I use STI?

I want to present my case, and know whether or not I should use STI solution. I am creating a message-board website and so far I have couple of Models: User, Topic, Post.. to make it clear: Post is like a comment for a Topic. Topic has title and…
socksocket
  • 4,271
  • 11
  • 45
  • 70
0
votes
1 answer

How to: Single Table Inheritance in DataMapper?

I'm learning Sinatra (1.3.2) and chose to use DataMapper (1.2.0) as ORM and an in-memory SQLite (1.3.6) DB to start. Two models, Books and Downloads, are sharing most attributes, so I looked into declaring a model for STI (Single Table Inheritance)…
0
votes
1 answer

Should I split this model and table?

I would like to create simple ResumeBank app. Issue: As user I would like to add only two Resumes. Forms for this both Resumes are different with only two fields. Resumes have 12 the same attributes but 2 are diferent. Question: Should I split that…
tomekfranek
  • 6,852
  • 8
  • 45
  • 80
0
votes
1 answer

STI routing error

Newbie working on his first rails application after studying Hartl's Rails Tutorial book & video cast. I'm using a STI model where: class User < ActiveRecord::Base class Kid < User class Parent < User User has the basic elements: name, email,…
iamreff
  • 15
  • 3
0
votes
1 answer

accepts_nested_attributes_for for STI Model

Here is my current model structure class Customer < ActiveRecord::Base self.inheritance_column = 'customer_type' has_one :contact accepts_nested_attributes_for :contact end class Vendor < Customer has_many :domains …
Addy
  • 1,817
  • 2
  • 18
  • 23
0
votes
2 answers

Route failing using STI

First SO post, but I've read so many. I'm new to Rails and building first site since studying Hartl's RailsTutorial. My issue is routing using STI. I believe the routes are set up correctly, but the subclass Kid doesn't find a "show" route. Class…
0
votes
1 answer

Rails subclassing and STI

I'm working on a Rails project OldApp that's using STI for some class Foo. At the moment we have a big, incremental, rewrite going on. To ease the pain we chose a rather unconventional approach. The new, namespaced, application NewApp lives as an…
Pascal
  • 5,879
  • 2
  • 22
  • 34
0
votes
1 answer

Getting an Active::Record::StatementInvalid on when running my spec on an STI model

So, here's my issue. I have a Model called AdminNotifications. It is belongs to an AdminUser model. There is a QuorumAdminNotification model which inherits from AdminNotification using STI. It is currently empty. When I run my spec I get this error…
1 2 3
25
26