# Use reflection to show the list

**URL:** <https://www.ruby-forum.com/t/use-reflection-to-show-the-list/190577>\
**Category:** Rails\
**Created:** [June 23, 2010, 8:11am UTC](https://www.ruby-forum.com/t/use-reflection-to-show-the-list/190577 "2010-06-23T08:11:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gandhi-tush](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/5daacb/32.png) [@gandhi-tush](https://www.ruby-forum.com/u/gandhi-tush)\
**Post date:** [June 23, 2010, 8:11am UTC](https://www.ruby-forum.com/t/use-reflection-to-show-the-list/190577/1 "2010-06-23T08:11:19Z")

</div>

Hi,  
I have two list

1. Groups that user part of
2. Group members list.

I trying to do this by using the reflection so that I will be having  
only one view in which depending on the action the object passed will be  
different.

Is there any way to find the all attributes of the object so that I will  
iterate on attributes array and list out the attribute values during  
rendering?

Any help appreciated.

Thanks,  
Tushar

---

<div class="post-metadata">

**Author:** ![gandhi-tush](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/5daacb/32.png) [@gandhi-tush](https://www.ruby-forum.com/u/gandhi-tush)\
**Post date:** [June 23, 2010, 5:50pm UTC](https://www.ruby-forum.com/t/use-reflection-to-show-the-list/190577/2 "2010-06-23T17:50:38Z")

</div>

Duno if it helps but

#view  
\<%= render :partial= “partials/values”, :collection =\> @values%\>

#action  
@values = Object.all

#\_value.html.erb  
\<% value.attributes.each do |a| %\>  
\<%= a.to\_a[0] %\>:  
\<%= a.to\_a[1]\>  
\<% end %\>

[“crypted\_password”, nil]  
[“username”, nil]  
[“password\_salt”, nil]  
[“persistence\_token”, nil]  
[“email”, nil]

Tushar G. wrote:

> Hi,  
> I have two list
> 
> 1. Groups that user part of
> 2. Group members list.
> 
> I trying to do this by using the reflection so that I will be having  
> only one view in which depending on the action the object passed will be  
> different.
> 
> Is there any way to find the all attributes of the object so that I will  
> iterate on attributes array and list out the attribute values during  
> rendering?
> 
> Any help appreciated.
> 
> Thanks,  
> Tushar
