Identifying the attributes of an object dynamically

Hello

I have an object 'details' which comprises of many attributes like

name
address.city
address.state
department.name

For a given object of 'details', I am trying to obtain the values of
some attributes from a given list ("name","department.name "), say from
the config. I tried iterating over the list and access the object's
attrib using instance_variable_get, but ended up with the error

(["name"] is not a symbol)

Is there something incorrect that I am trying to do ?

~Shankar.

Hello

I have an object 'details' which comprises of many attributes like

name
address.city
address.state
department.name

For a given object of 'details', I am trying to obtain the values of
some attributes from a given list ("name","department.name "), say
from
the config. I tried iterating over the list and access the object's
attrib using instance_variable_get, but ended up with the error

Assuming you are talking about an ActiveRecord object, database
attributes are not instance variables. attributes surprisingly enough
contains all the attributes.

Fred

Ah! yes.. thanks for pointing that out, Fred. But is there something
like 'attributes_get' that I should be using to get the values of the
attribute in my case ?

~Shankar.

Aww.. was really a very dumb question to ask... :frowning:

object.attributes[<attr_name>] would obviously give the value..

Thanks for the help, Fred. Appreciate it !!

~Shankar.