[Rails] polymorphic association question

2010-07-13 Thread joep
Question from a relative newbie. I have the following models (rails -v Rails 2.3.8) class Node < ActiveRecord::Base belongs_to :containable, :polymorphic => true end class Root < ActiveRecord::Base has_one :node, :as => :containable validates_presence_of :owner validates_numericality_of

Re: [Rails] Polymorphic association question

2010-02-08 Thread Mat Brown
The polymorphic :locatable association implies a :locatable_type and :locatable_id column. These columns reference a row in an arbitrary table identified by :locatable_type so no join table is needed. On Feb 7, 2010 11:02 PM, "Sean Six" wrote: This is an example from the geokit plugin which I am

[Rails] Polymorphic association question

2010-02-07 Thread Sean Six
This is an example from the geokit plugin which I am trying to reproduce. class Location < ActiveRecord::Base belongs_to :locatable, :polymorphic => true acts_as_mappable end class Company < ActiveRecord::Base has_one :location, :as => :locatable # also works for belongs_to associations