Forum: Ruby on Rails cattr_accessor for all attributes

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
970ef3bb8a3dfdab9619a73bd47cff86?d=identicon&s=25 bide (Guest)
on 2009-02-05 17:02
(Received via mailing list)
Hi,

I´ve created an "acts_as" plugin where the user can add several
attributes of his choice to the model.
Now I´m looking for a way to allow the users to access all attributes
without changing the plugin code

e.g., now I set the accessors like this in the plugin code:
   cattr_accessor :first_name, last_name

I am looking for something like this:
   attr_accessor :all

Thanks for your help,
bide
A4911c2072d2c07e17d79c47559b4767?d=identicon&s=25 unknown (Guest)
on 2009-02-06 01:03
(Received via mailing list)
obj.instance_variables might be the answer you are looking for,
although attr_accessor :name will not create the corresponding
instance variable.

Also, are you sure :first_name and :last_name should be class
attribute accessors and not instance ones (so plain attr_accessors)?

Balint
This topic is locked and can not be replied to.