single-table-inheritance
In Ruby on Rails, if we generated a model "Animal", and now want to have "Dog", how should we do it?
say, if we generated a model rails generate model animal name:string birthday:date and now we want to create other model to inherit from it (such as Dog and Cat), should we use rails generate model[详细]
2023-01-14 20:46 分类:问答It's this a bug in rails? about single table inheritance;
class Parent < ActiveRecord::Base end class Sub < Parent end class SubSub < Sub end >> SubSub.create :name => \'name1\'[详细]
2023-01-14 00:12 分类:问答Creating the same model from multiple data sources
This is mostlyof a design pattern question.I have one type of model that I\'m going to get the data to create them from multiple sources.So for example one record my be created from an API where anoth[详细]
2023-01-11 10:49 分类:问答How to cast an ActiveRecord object to another class when using STI?
I\'m currently using ActiveRecord single table inheritance. How can I cast one of my models from type A to B? They h开发者_如何学Goave the same parent.#becomes is what you are looking for:[详细]
2023-01-10 09:16 分类:问答Should you use single table inheritance or multiple tables that are union-ed in a view?
Let\'s say you have a notes table. The note can be about a particular account, orderline or order. Notes that are about the account do not apply to any specific orderline or order.[详细]
2023-01-09 23:36 分类:问答Changing type of ActiveRecord Class in Rails with Single Table Inheritance
I have two types of classes: BaseUser < ActiveRecord::Base and User < BaseUser which acts_as_authentic using Authlogic\'s authentication system. This inheritance is implemented using Si[详细]
2023-01-08 02:07 分类:问答Hibernate, single table inheritance and using field from superclass as discriminator column
I have following kinds of classes for hibernate entity hierarchy. I am trying to have two concrete sub classes Sub1Class and Sub2Class. They are separated by a discriminator column (field) that is def[详细]
2023-01-07 11:25 分类:问答Controller inheritance in Ruby on Rails -- model and controller access in parent class
I am using single table inheritance in StudentHours and TeacherHours, which have a parent Hours. 开发者_运维问答The model code is mostly in hour.rb, and very little in student_hour.rb and teacher_hou[详细]
2023-01-06 13:36 分类:问答Rails object inheritance with belongs_to
I have a simple has_many/belongs_to relationship between Report and Chart. The issue I\'m having is that my Chart model is a parent that has children.[详细]
2023-01-03 22:32 分类:问答How do I so a select input for a STI column in a Rails model?
I have a model with single-table inheritance on the type column: class Pet < ActiveRecord::Base TYPES = [Dog, Cat, Hamster][详细]
2023-01-03 16:31 分类:问答
加载中,请稍侯......