sti Questions

3

Solved

I've been playing around with STI and belongs_to / has_many relationships and I'm a bit confused. I have a few questions based on a model configuration similar to: class Parental < ActiveRecor...

4

Solved

I'm getting some strange behaviour when fetching collections from a has_many association with rails 3 when using STI. I have: class Branch < ActiveRecord::Base has_many :employees, class_name:...
Ornithorhynchus asked 20/6, 2012 at 11:21

2

Solved

I've got a pretty simple (I think) single-table inheritance (STI) setup in my Rails app. There is a User model with a nested resource Post. Using STI, I have it so that some Posts can be Post::Urg...

2

Solved

I am using STI in a Rails app and in order to not have to define routes for all subclasses, I put the following in each subclass: def self.model_name Mapping.model_name end In the above example...
Firer asked 8/4, 2015 at 23:34

7

I have a Client resource with 2 types: Person and Company. routes.rb: resources :clients resources :people, :controller => "clients", :type => "Person" resources :companies, :controller =&g...
Sherwin asked 13/8, 2014 at 8:31

6

Solved

Because of company rules I can't use our domain class names; I am going to use an analogy instead. I have a table called projects which has a column called 'type' with possible values as 'indoor' &...
Kendallkendell asked 25/4, 2014 at 12:26

0

It's gonna get a bit tricky. So, I have a forum app consisting of Section entities. And the forum also has Char entities (who write posts and create topics) and CharGroup entities for grouping ch...
Delainedelainey asked 25/6, 2017 at 8:39

3

Solved

On Rails 3.2.6, I have a class that inherits from ActiveRecord::Base: class Section < ActiveRecord::Base ... end When I inherit from this class, Rails will assume I want STI: class AnotherS...
Abduct asked 26/7, 2012 at 19:2

2

Previously, I asked this question about compound indexes on polymorphic foreign keys in ActiveRecord. The basis of my question was my understanding that indexes should be based on the cardinality o...
Hiett asked 9/2, 2011 at 16:1

3

Solved

EDIT I have edited this from the original to make it easier to understand. I understand the Object Relationship Impedance problem. I understand Rails STI and Polymorphism (the Rails way and that...

2

I have a set of STI subclasses inheriting from a User base class. I am finding that under certain conditions inside a subclass' definition, queries on the subclasses do not correctly use the type c...

1

I have the a basic events table, and want to have sub-tables for each event type (hiking, party, riverrun, etc). I see a lot of old (2011/2012) posts regarding CTI, MTI and STI. Some solutions wo...

4

Solved

I am using Single Table Inheritance for managing different types of projects. Models: class Project < ActiveRecord::Base end class SiteDesign < Project end class TechDesign < Project e...
Lesleylesli asked 16/10, 2009 at 15:4

2

Solved

On Rails 3.1 RC6, given class Animal < ActiveRecord::Base default_scope where(legs: 4) end The following does not work as expected: class Man < Animal default_scope unscoped.where(legs:...
Starrstarred asked 30/8, 2011 at 5:53

3

Solved

I implement a class hierarchy using STI pattern class A scope :aaa, where([someField]:[someValue]) end class B < A end The problem is that when I try to call something like: B.limit(5).aaa...
Taishataisho asked 17/9, 2012 at 14:49

3

Solved

I have the following model class Event < ActiveRecord::Base has_many :attendances class Attendance < ActiveRecord::Base belongs_to :user class Student < User has_one :student_detail ...
Brand asked 6/1, 2015 at 2:34

2

Solved

I plan to use STI in Rails with the following models: class Promo < ActiveRecord::Base end class Event < Promo end class Discount < Promo end There are just a couple of differences in...
Bicknell asked 11/12, 2014 at 15:46

4

So, I have the following: class Product < ActiveRecord::Base # Has a bunch of common stuff about assembly hierarchy, etc end class SpecializedProduct < Product # Has some special stuff th...
Annunciation asked 20/5, 2013 at 18:5

2

Solved

I'm having problems with AR trying to build associations of models that inherit from others. The problem is the associated models are being saved to the database before the call do the save method....
Ichthyosaur asked 7/3, 2013 at 6:36

1

Solved

I'm running with some issues trying to combine STI and polymorphic associations with the following structure : class User < ActiveRecord::Base end class Runner < User has_many :subscriptio...
Animalism asked 19/2, 2014 at 16:27

1

Solved

I have got a class, that is the base of some other classes that specializes the behavior: class Task < ActiveRecord::Base attr_accessible :type, :name, :command validates_presence_of :type, :...
Ruggles asked 20/8, 2013 at 9:53

2

I've seen similar posts already, but couldn't quite get the answer I needed. I have a User model and using STI a Student model that is a type of User. When I create a new Student, Devise logs in ...
Nereus asked 28/8, 2011 at 23:23

3

Solved

Probably a confusing title, but not sure how else to put it. Example should make it clearer. I have many different models that share many of the same attributes. So in each model I have to specify ...
Boaster asked 25/4, 2012 at 14:4

2

Solved

I have a Book and Download model that share many attributes, so my goal is to inherit the common attributes from a DownloadableResource model. Had a look at STI, but I went the abstract base model ...
Judkins asked 30/12, 2012 at 6:20

1

Solved

Setup So here's a scenario which I'm finding is rather common once you decide to play with STI (Single Table Inheritance). You have some base type with various subtypes. Person < (Teacher,...
Dodona asked 25/11, 2012 at 13:40

© 2022 - 2024 — McMap. All rights reserved.