Answer the question
In order to leave comments, you need to log in
How to display data using has_many belongs_to binding methods?
There are models:
User has_many tests
Test belongs_to User
There is a /users/index page where user cards are displayed.
To display information from the tests table, I use
<% @users.each do |user| %>
<%= user.tests.each do |f| %>
<%= f.title %>
<% end %>
<% end %>
[#<Test id: 1, title: "number 1", describe: " blablabla",
user_id: 1, created_at: "2014-12-10 13:22:15",
updated_at: "2014-12-10 13:22:15">]
Answer the question
In order to leave comments, you need to log in
<% @users.each do |user| %>
<% user.tests.each do |f| %>
<%= f.title %>
<% end %>
<% end %>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question