Forum: Ruby on Rails has_many :addresses, :as => :addressable

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
3e3e9c160cf5f5f9a6522626275136ce?d=identicon&s=25 Rath -. (rath)
on 2006-03-23 00:24
I just got the Rails Recipies and I'm looking the Recipe 17.

class Person < ActiveRecord::Base
   has_many :addresses, :as => :addressable

class Company < ActiveRecord::Base
   has_many :addresses, :as => :addressable

class Address < ActiveRecord::Base
   belongs_to :addressable, :polymorphic => true

At the beggining I had some problems because "polymorphic" was not
supported on Rails1.0.0 then I update rails. In the console everything
works fine but when I'm trying to list the people I'm getting the
"Unknown key(s): as" error.
Does anyone have a clue of what's going on?


This is what I have updated

C:\rails>gem update rails --source
Upgrading installed gems...
Updating Gem source index for:
Attempting remote upgrade of rails
Attempting remote installation of 'rails'
Install required dependency activesupport? [Yn]  y
Install required dependency activerecord? [Yn]  y
Install required dependency actionpack? [Yn]  y
Install required dependency actionmailer? [Yn]  y
Install required dependency actionwebservice? [Yn]  y
Successfully installed rails-
Successfully installed activesupport-
Successfully installed activerecord-
Successfully installed actionpack-
Successfully installed actionmailer-
Successfully installed actionwebservice-
Installing RDoc documentation for activesupport-
Installing RDoc documentation for activerecord-
Installing RDoc documentation for actionpack-
Installing RDoc documentation for actionmailer-
Installing RDoc documentation for actionwebservice-
Gems: [rails] updated

C:\rails>rails -v
Rails 1.0.0
Runar Ingebrigtsen (Guest)
on 2006-03-23 14:47
(Received via mailing list)
tor, 23,.03.2006 kl. 00.24 +0100, skrev Rath:
> end
Seems broken. I get:
>> Company.find(1).create_address
NoMethodError: undefined method `create_address'

It's working great if i'm using:
	has_one :address, :as => :addressable
This topic is locked and can not be replied to.