Answer the question
In order to leave comments, you need to log in
How to fetch from a database in rails?
Hello.
Please tell me why it does not work to make a selection from the database?
It is necessary to take all users who have status = true.
I do it like this:
def index
@users = User.find_by status: false
end
<tbody>
<% @users.each do |user| %>
<tr>
<td><%= user.name %></td>
<td><%= user.surname %></td>
<td><%= user.age %></td>
<td><%= user.status %></td>
<td><%= user.enter_date %></td>
<td><%= user.doctor_id %></td><code lang="javascript">
</code>
<td><%= user.diagnoz %></td>
<td><%= link_to 'Переглянути', user %></td>
</tr>
<% end %>
</tbody>
def index
@users = User.all
end
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question