Not surprising you're getting problems. By moving from a pure STI system to your current system you are horribly breaking the patterns you are using by intermingling parts of one with parts of another I'd personally go for something like: class Project false t. String :name, :null => false t.
Text :description t. Timestamps end add_index :project_types, :model_name, :unique => true #all project types that are used. Models_names = {"SiteDesign" => "Site design", "TechDesign" => "Tech design"} #key for model_name and value for name models_names.
Each do |key,value| p = ProjectTypes.new(); p. Model_name = key p. Name = value p.
Save end end def self. Down drop_table :project_types end end class CreateProjects false t. Text :description t.
Text :concept t. Integer :client_id t. Timestamps end end def self.
Down drop_table :projects end end It just cleans things up and it also helps clarify what you're doing. Your 'ProjectType' table is purely for extra data, your inheritance tree still exists. I've also thrown in some checks to make sure your project type is always set (and correctly, based on the model name) and stops you from changing project type once it's been saved by making the attribute read only.
Not surprising you're getting problems. By moving from a pure STI system to your current system you are horribly breaking the patterns you are using by intermingling parts of one with parts of another. I'd personally go for something like: class Project false t.
String :name, :null => false t. Text :description t. Timestamps end add_index :project_types, :model_name, :unique => true #all project types that are used.
Models_names = {"SiteDesign" => "Site design", "TechDesign" => "Tech design"} #key for model_name and value for name models_names. Each do |key,value| p = ProjectTypes.new(); p. Model_name = key p.Name = value p.
Save end end def self. Down drop_table :project_types end end class CreateProjects false t. Text :description t.
Text :concept t. Integer :client_id t. Timestamps end end def self.
Down drop_table :projects end end It just cleans things up and it also helps clarify what you're doing. Your 'ProjectType' table is purely for extra data, your inheritance tree still exists. I've also thrown in some checks to make sure your project type is always set (and correctly, based on the model name) and stops you from changing project type once it's been saved by making the attribute read only.
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 with Project object ProjectTypes object it always returns null. Getting projects associated with ProjectTypes project is OK.
Is there way to make it works properly?
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.