# Displaying relationship attributes in MTM relationships

**URL:** <https://www.ruby-forum.com/t/displaying-relationship-attributes-in-mtm-relationships/87840>\
**Category:** Rails\
**Created:** [March 6, 2007, 10:48am UTC](https://www.ruby-forum.com/t/displaying-relationship-attributes-in-mtm-relationships/87840 "2007-03-06T10:48:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vishwaraj](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e19adc/32.png) [@Vishwaraj](https://www.ruby-forum.com/u/Vishwaraj)\
**Post date:** [March 6, 2007, 10:48am UTC](https://www.ruby-forum.com/t/displaying-relationship-attributes-in-mtm-relationships/87840/1 "2007-03-06T10:48:03Z")

</div>

I have following many to many relationship:  
class Service \< ActiveRecord::Base  
has\_many :service\_dependencies  
has\_many :dependents, :through =\> :service\_dependencies  
end

class ServiceDependency \< ActiveRecord::Base  
belongs\_to :service  
belongs\_to :dependent, :class\_name =\> ‘Service’, :foreign\_key =\>  
‘dependent\_service\_id’  
end

However, in my schema the MTM table service\_dependencies has few  
relationship attributes as well, e.g. impact, severity, etc. along  
with the foreign keys.

Right now, I’m displaying the dependent services’ fields in following  
manner:

\<% for dependents in @service.dependents %\>  
**Service Name:**  
 \<%=h dependents.send(“service\_name”)  
%\>  
  
\<% end %\>

I want to display the relationship attributes, impact, severity as well,  
could someone please help me by letting me know how to access them in my  
view page?
