Forum: Ruby on Rails cattr_accessor for all attributes

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.
bide (Guest)
on 2009-02-05 18:02
(Received via mailing list)

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,
unknown (Guest)
on 2009-02-06 02: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)?

This topic is locked and can not be replied to.