Displaying 20 results from an estimated 20000 matches similar to: "Single Table Inheritance and controllers"
2006 Aug 17
0
single-table inheritance and select
I''m getting some weirdness trying to use a select widget to choose
the type from a collection of three objects sharing a database table
via single-table inheritance (STI). I''d be grateful for any advice on
whether it''s a bug or a feature, if a feature why and how I can more
easily do what I''m trying to do.
So I have the usual STI setup, with a
2006 Mar 18
1
Fixtures and single table inheritance
I''m wondering what the accepted method for doing unit tests on STI models is.
I tried to create a fixture for the class but Rails tries to load that
data into the non-existent child table. I could create a fixture named
for the real, parent table, but then it would be very difficult to
test for the individual functionality and integrity of each sub-class.
I saw this page
2005 Apr 20
4
acts_as_list and single table inheritance
in a single table inheritance model, rails will automatically set the
scope for acts_as_list to the ''type'' field as well as any other scope
conditions we provide.
Is there a way to disable this? i want to use STI but I want
acts_as_list to disregard the class type when getting/setting
positions.
thanks
alan
2006 Jul 31
0
acts_as_list with single table inheritance
I have a question about where to decorate my classes with acts_as_list.
I am using single table inheritance and i have a base class LookupItem.
There are 5 child classes: Priority, Probability, RiskRating, Status, and
RiskManagementItem.
Each of these 5 items needs to act as a list. Should I use acts_as_list on
each child class or should it go on the parent LookupItem class? I''m
2005 Sep 29
0
Single Table Inheritance and rhtml docs
Is there any way to wire the .rhtml files in app/views into Rails''
Single Table Inheritance mechanism?
So given:
class Bar < Foo
The STI mechanism is generating the objects correctly when it hydrates
them out of the db, but when it goes to rendering pages, it pulls
everything from app/views/foo and doesn''t touch app/views/bar.
I can of course hook in manual type-checking
2007 Nov 14
1
New Foxy Fixtures (Rails 2) & STI (Single Table Inheritance)
I''ve got some problems right now using the new model for relationships
in fixtures (by label, not by id) and STI. What I''ve got, is a couple
of models:
Attachment
--> FileDownload
Version
Version has_one file_download with file_download_id on the versions
table
In my fixtures, I have two FileDownloads in my attachments.yml like
so:
hemingway_alpha_zip:
size: 100
2006 Oct 13
1
Edge rails, single table inheritance and keeping multiple classes in a single file
So is the official stance as per edge rails that multiple class
definitions must go into separate files? I was trying to use STI with
acts_as_attachment, to have all my attachment classes go into a single
file, for example:
attachment.rb
class Attachment < ActiveRecord::Base
end
class UserPicture < Attachment
belongs_to :user, :foreign_key => ''owner_id''
2006 Jan 06
3
Single table inheritance - HowTo?
Hi,
As per another member''s suggestion, I''m trying to user STI. So I have
this table:
CREATE TABLE `settings` (
`id` int(11) unsigned NOT NULL auto_increment,
`type` char(40) NOT NULL default ''General'',
`name` char(40) NOT NULL default '''',
`value` char(128) NOT NULL default '''',
`updated_on` datetime default NULL,
2006 May 21
2
acts_as_taggable and single table inheritance
I''ve set up a couple of STI models like such that we get something like
this...
class A < AR:Base
class B < A
acts_as_taggable
class C < A
acst_as_taggable
(using the acts_as_taggable plugin)
I can tag things just fine this way, the problem I encounter is that the
taggings are listed with the base class ("A") and not the appropriate
subclass ("B"
2006 Apr 03
1
Single table inheritance and relations
All,
I''ve a question concerning STI in Rails. Let''s say I''ve a Person class
and two classes that inherit from Person: User and Customer. In the DB
I''ve the people table to store both instances of User and Customer.
Now, let''s say I also have Address class, which references a Customer,
and each customer has many addresses. How should I name the
2007 Jul 22
4
single table inheritance problem
Hallo,
I am having a very strange Problem with STI in my application.
setup:
- two tables one called "wikis" on called "categories" with a hbtm
relationship.
- the wikis table is the sti one with a model PageWiki being extended
from Wiki (and the correspondig type column)
Following happens:
- server restart
- get :wikis, :show_pages
- in show_pages the first line says
2005 Dec 29
9
Single Table Inheritance
Hi all,
Quick question for STI. With the following setup:
class Company < AR::Base; end
class Firm < Company; end
Why does Firm.find(:all) return all Companies, not just those that have
type==''Firm''?
--
Alex
2006 Jan 15
2
single table inheritance: change object ''type'' after create?
Hey folks,
I''m trying to keep track of couple of different kinds of "entities" in
my rails app: "people", "organizations", and "committees". I have a
single Entities table in the database, and I''m using Single Table
Inheritance to keep the different subclasses in the same table, with a
field "type".
My problem comes when
2006 Jul 06
5
Single table inheritance
I''m having a class called Person, with subclasses as goalkeeper,
forward, defender.
Now a person can be a forward as well as a defender or a goalkeeper.
I want to use single table inheritance like :
class Goalkeepr < Person
end
And not have multiple boolean columns like in my people table like is
is_goalkpeer, is_forward, is_defender.
How do I go about it ?
Thanks,
Pratik
--
rm
2006 Aug 30
1
Single Table Inheritance with self-referential join
Please tell me if this train of thinking makes sense, I need help on
solving this association model problem:
I am doing an app that creates and manages stereoscopic images, one
stereoscopic image is formed by two photos, say photo1 and photo2
The user uploads photo1 and then photo2 and gets a preview if he likes
the preview he/she authorizes it and gets a final stereoscopic image
All this
2006 Jul 26
3
Polymorphic Association with Single Table Inheritance?
Hello,
is it possible to setup a model/table schema like this:
Groupable --> Membership <-- Group
^ ^
| |
User UserGroup
I tried the following but failed:
Groupable (table with ''type'' column)
has_many :memberships, :as => :groupable
has_many :groups, :through => :memberships
2009 Oct 13
2
Single Table Inheritance (STI) Broken: NameError
Some how I''m getting NameError: uninitialized constant when accessing a
child models that inherits form the parent model. However, if I access
the parent model first, then the child model is resolved.
What am I doing wrong? My steps are below...
Thanks,
Francis.
> ./script/generate model Blah type:string
class CreateBlahs < ActiveRecord::Migration
def self.up
create_table
2006 Nov 04
0
newbie: Single Table Inheritance
Hello,
I have been experimenting with Single Table Inheritance as described in the More Active Record chapter in Agile Development with Rails.
I have started with an object model with three classes x, y and z (for brevity), where y < x and z < y. (I will want to extend this model further to subclass y with other classes.)
I have created a table called x (plural) in the database with
2006 Jul 31
3
Polymorphic associations and single table inheritance
Running into an interesting problem that at first glance appears to be a
bug in the AR association code. However, it''s explicitly coded this way
so I''m not so sure.
I have some code like this:
class Address < ActiveRecord::Base
belongs_to :addressable, :polymorphic => true
end
class Person < ActiveRecord::Base
has_many :addresses, :as => :addressable,
2009 Jun 29
3
Table Inheritance based on a function
Hello,
we have a problem in a CMS project that we believe is basic for RoR
developement and could concern others as well - or have already:
RoR implements the ''Single Table Inheritance'' (STI) Pattern:
http://www.martinfowler.com/eaaCatalog/singleTableInheritance.html
.. through its ''ActiveRecord'' ORM.
The Fowler example mentions a ''type''