similar to: Best practice for registering/discovering STI subclasses?

Displaying 20 results from an estimated 10000 matches similar to: "Best practice for registering/discovering STI subclasses?"

2006 Mar 01
4
STI, subclasses and callbacks
I have a STI class tree. I want to set some default values (calculated values so I can''t set it in the database as defaults) on every created instance regardless of what subclass is actually instantiated. So I figured adding a after_create callback in the top class in the hierarchy should do the trick. It seems it doesn''t get called :( Code: class SuperClass <
2009 May 08
3
STI and subclassing twice
I''m trying using STI to implement a hiearchy similar to this: script/generate scaffold name:string type:string class Person < ActiveRecord::Base; end class Customer < Person; end class Employee < Person; end class Developer < Employee; end I.e., there are two levels of inheritance (Developer < Employee < Person). When creating a Customer, Rails understands
2006 Apr 02
0
STI and through
I''m trying to understand how to do the following, but am finding myself stuck. I have three main tables; here are the first two: CREATE TABLE reference_items ( "id" integer primary key, "type" varchar(20), "title" varchar(255), "year" year(4) ); CREATE TABLE "agents" ( "id" integer primary key, "type"
2006 Jan 17
10
Is STI the only way to do inheritance?
I''m currently coding a system which must store multiple contact methods for a user (phone, email, postal address etc). I''m planning a fairly straightforward inheritance hierachy for these, where each different method inherits from something like a ContactMethod class. The only mention of ActiveRecord support for inheritance I can find in the Wiki and the Agile Web Dev book is
2006 May 05
4
STI and HABTM
Hey gang, How does STI work with HABTM? For instance...let''s say I have the following models ----- Category < ActiveRecord::Base Item < ActiveRecord::Base Product < Item Deal < Item ----- Each product or deal can have categories. Would I then setup Item with has_and_belongs_to_many :categories, then create a table categories_items ??? Is there a better way to do it?
2006 Jan 19
3
Why does Object.subclasses_of ignore subclasses within modules?
ActiveSupport provides a method Object.subclasses_of, shown below: def subclasses_of(*superclasses) subclasses = [] ObjectSpace.each_object(Class) do |k| next if (k.ancestors & superclasses).empty? || superclasses.include?(k) || k.to_s.include?("::") || subclasses.include?(k) subclasses << k end subclasses end Can anyone shine some light on why
2006 Dec 28
2
STI, controllers and views
Hello, I have set up that uses single table inheritance. I have a number of model subclasses following the example in AWDWR that uses Manager < Employee < Person. First question. Do I need to create controller classes for each? I don''t think I do because a single controller should be able to shunt the data between the models and the views. Second question. Say I have a view
2007 May 29
0
STI and Active Record
Hey, I''m trying to use STI in my models, while writing a little cms. A have a model called Page and some subclasses like ContentPage, Sysfolder etc. Some classes share similar attributes, so I use STI and one table for all types. Now I''m writing a form for edititing a page and I want to have the opportunity to change the type of it at runtime. But that seems to be a problem:
2007 Oct 27
0
STI vs Polymorphic Associations
I have a MasterEvent model. It has attributes that is required by another model Event. The user selects the MasterEvent model and I create the Event model by merging the attributes of the selected MasterEvent with the attributes that were presented for the Event model in the form. I have association declarations in the MasterEvent and Event models. If I use STI does the subclasses inherit the
2011 Apr 15
2
sti + namespace
I''m spidering historical weather data from various sources. I have a WeatherStation class that is begging for an STI implementation: a WeatherStation is associated with a specific weather service, and each weather service has its own protocol for fetching weather data, but most of the code is can be shared in the WeatherStation parent class. Ergo STI. But there are a lot of weather
2006 Jun 17
5
STI versus Composition...or the headaches of one big table
Guys, I have a relationship between model classes that I believe is best represented by inheritance, but the likelihood that things will change often is driving us to composition instead. So, I have a class called Autos, and subclasses called Suvs, Minis, Mids, Sports, for example. We have been requested to avoid the STI approach to this, because of fear of a quickly growing table with
2012 Feb 17
2
DatabaseModifiedError on get_data - best practice?
Hi, I have previously had a problem with getting this error on a get_mset call, and solved it by subclassing XapianEnquire with a backoff-and-retry algorithm (as suggested by this list, many thanks!). However, I now get it intermittently when calling get_data on a XapianDocument. The same solution doesn't seem to be quite as easy in this case, because: 1. The document is not instantiated
2019 Feb 10
0
AD Backup Best Practice
On Sun, 10 Feb 2019 14:13:27 +0100 Viktor Trojanovic via samba <samba at lists.samba.org> wrote: > I'm currently reviewing my own backup strategy for Samba and I > realize it is not in line with best practices provided in the Wiki. ( > https://wiki.samba.org/index.php/Back_up_and_Restoring_a_Samba_AD_DC) > Said best practices, however, seem a bit like a nightmare to me. >
2006 Apr 22
6
STI and type tables?
So by default to get STI, I would have something like: create_table :items do |t| t.column "type", :string t.column "title", :string end But if I want to store those type values in a separate table, such that I have ... create_table :items do |t| t.column "item_type_id", :string t.column "title", :string
2006 Dec 20
6
select lists - DB best practice
Hey guys, I''m putting together an app with user profiles, and each user will be able to update a section called ''quick stats''. This will involve lots of drop down lists with options like ''hair colour'', ''height'', ''Location'' etc etc. The way I m thinking about doing it is to create new table for each group of options
2006 May 14
2
object class with STI and Polymorphic Assoc''s.
Hi, lets say I have a a table, "Linkings" that I am using for polymorphic associations. One of the associations is to the "person" table, and there are several other associations. "Person" has 2 types, "slacker" and "suckup". It is modelled as such: class Linking < ActiveRecord::Base belongs_to :person belongs_to :linkable, :polymorphic
2006 Sep 25
3
Subclasses - help required
Hello all and hoping for some insight a project manger type of application, staff are assigned to projects, but each staff has varied roles for different projects... STI does not seem to be applicable here Imagine a table staffs... id int name varchar blah.... is_manager int 1 is_engineer int 1 is_producer int 1 and projects... id name manager_id engineer_id producer_id how is the best way
2019 Feb 10
0
AD Backup Best Practice
A good practice is to have at least 2 DCs in a domain. If one crashes, you can reinstall one from scratch, join it to the domain and it will synchronize with the safe one. And your services should not stop in the meantime. That doesn’t prevent us from setting up backups, but that reduce risks a lot. :-) G. > Le 10 févr. 2019 à 17:07, Viktor Trojanovic via samba <samba at
2007 Jan 17
0
Models and Modules and subclassing, oh my!
So, our application has a large number of models at this point, and I''m getting a bit worried about people having to use long names, as well as clashes in the global namespace. More recently I wanted to add a new table with some STI subclasses of that table... module Portal end class Portal::Base < ActiveRecord::Base belongs_to :widget end However, Widget is a top level class,
2006 Apr 06
1
ActiveRecord subclassing best practises
Hi, I want some of my models to inherit from a custom ActiveRecord::Base class. Where is the best place to put this custom subclass? Actually, I just wanted to translate the default validate message so maybe there was a better thing to do than subclassing ActiveRecord::Base. Thanks Oscar --------------------------------- How low will we go? Check out Yahoo! Messenger?s low PC-to-Phone