search for: understandingpolymorphicassoci

Displaying 8 results from an estimated 8 matches for "understandingpolymorphicassoci".

2006 Jun 03
8
confused about ActiveRecord relationships
I am very confused about where to put the belongs_to and the has_one (and other relationship identifiers). I have read the RDoc and the agile book many times about this and I think i still see it backwards. Let me outline my app so you have an understanding... I have 2 tables: Schools { id, school_name, address_id } and Addresses { street1, street2, city, state, zip, country } *** this
2006 Jan 27
4
acts_as_whatever
Hi there, I love the acts_as_* family that rails uses. I''ve also found I can create something similar by dropping the following code into my activerecord classes: class MyClass < ActiveRecord::Base class << self alias_method :count_with_unapproved, :count end def self.find(*args) options = extract_options_from_args!(args) if options[:conditions].nil? options[:conditions] =
2006 Mar 24
7
Polymorphic associations?
I''ve read the stuff about polymorphic associations here: http://wiki.rubyonrails.org/rails/pages/UnderstandingPolymorphicAssociations But I''m not sure what exactly they are and what their advantage is. Are they the same as HABTM, but they''re "two-way"? Joe -- Posted via http://www.ruby-forum.com/.
2009 Feb 23
2
geokit - using :through to connect models
hello.. i am currently trying to use :through to attach two of my models together using geokit. for some reason, i am running into a problem: ArgumentError: Unknown key(s): as i have two models, one that is geocoded, and one that belongs to that model. the models look like: ,----[ employer.rb ] | class Employer < ActiveRecord::Base | acts_as_mappable | before_validation_on_create
2006 May 10
4
Single Table Inheritance problem
I have two tables I am using single table inheritance with: Page and Item. "Page" has many "Items"; "Item" belongs to "Page". Item Model: class Item < ActiveRecord::Base end class Article < Item belongs_to :page end Page Model: class Page < ActiveRecord::Base end class Issue < Page has_many :articles end In my controller, when I
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
2009 Jan 18
5
Modeling complex associations
Hi, Is there any default way to model something like the following situation in ActiveRecord?: A company has_many :buildings which are associated to :company, e.g. in a polymorphic way. Moreover one and only one of the buildings is the company''s headquarter. Thinking in terms of the database, I''d prefer to add an owning association, an thus have a has_many :buildings plus a
2007 Oct 04
12
Rails' abilities fitting?
Hi, I''m looking at developing a reasonably complex web application, where most of the complexity actually lays in the database and the queries I need run on it. Some "classes" or models need to consist of an assembly of several tables. It would be trivial enough for me to code these queries in SQL, but as far as I understand Rails is trying to hide the database as