Closed RuiPedroLeal closed 10 years ago
Upfront, I'm using ruby 1.9.3 and rails 3.2.15. Also, using the '~>0.1' modifier on my gemfile.
Have 2 simple models:
class Person < ActiveRecord::Base belongs_to :country belongs_to :affiliation, :class_name => "Entity" attr_accessible :active, :email, :name, :personizable_id, :personizable_type, :phone, :shortcv, :url acts_as_superclass end class Member < ActiveRecord::Base belongs_to :position belongs_to :function attr_accessible :alias, :bibtext_name, :cv, :order, :photo, :sname, :state acts_as :person, :as => :personizable end
The person migration includes:
create_table :people do |t| t.integer :personizable_id t.string :personizable_type end
From the rails console i'm able to do:
m = Member.first m.name (an attrib from Person)
But can't do:
p = Person.first p.specific (returns nil)
The specific db entry has the correct ID and personizable_type as 'Member'
Any help please?
Sorry everyone, but after some digging on the code (and a coffee) i've managed to understand what was missing:
acts_as_superclass :as => :personizable
Probably could help someone.
Regards!
Upfront, I'm using ruby 1.9.3 and rails 3.2.15. Also, using the '~>0.1' modifier on my gemfile.
Have 2 simple models:
The person migration includes:
From the rails console i'm able to do:
But can't do:
The specific db entry has the correct ID and personizable_type as 'Member'
Any help please?