Mike W
Mike W

Reputation: 401

rails-admin has_many association to display in model

I have a model user which has_many documents. On the show page for the user model, I'd like to show the name for each of my documents.

at the moment I'm able to list all documents object, but not accessing the details for each of those documents.

thanks for your help

Upvotes: 1

Views: 358

Answers (1)

Abdulaziz
Abdulaziz

Reputation: 2211

In the view template, you can have something like this:

<% user.documents.each do |document| %>
  ID: <%= document.id %>
  Name: <%= document.name %>
<% end %>

Upvotes: 1

Related Questions