Topic: MTM relationship with relationship attributes
I have following many to many relationship:
class Service < ActiveRecord::Base
has_many :dependents, :through => :service_dependencies
class ServiceDependency < ActiveRecord::Base
belongs_to :dependent, :class_name => 'Service', :foreign_key => 'dependent_service_id'
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:
<%=h dependents.send("service_name") %>
<% for dependents in @service.dependents %>
<b>Service Name:</b><br> <%=h dependents.send("service_name") %><br>
<% end %>
I also want to display the relationship attributes, could someone please help me by letting me know how to access them in my view page?