Я использую Rails 5.2.2. Я установил Bullet Gem и получил его на bullet.log
:
2019-01-18 13:22:02[WARN] user: jordan
GET /customers/37
USE eager loading detected
Account => [:user]
Add to your finder: :includes => [:user]
Call stack
/home/jordan/Desktop/Rails/acc/app/views/customers/show.html.erb:64:in `block in _app_views_customers_show_html_erb___50963452045031815_70292526903360'
/home/jordan/Desktop/Rails/acc/app/views/customers/show.html.erb:62:in `_app_views_customers_show_html_erb___50963452045031815_70292526903360'
Согласно руководству, я добавил includes(:user)
в мой account.rb
файл. Я пытался добавить его к действию индекса и показать действие, но это предупреждение появляется снова и снова.
Account.rb:
class Account < ApplicationRecord
belongs_to :user
belongs_to :customer
end
accounts_controller.rb:
def index
@accounts = Account.includes(:user).where(customer_id:params[:id])
end
private
def set_account
@account = Account.includes(:user).find(params[:id])
end
show.html.erb (клиенты 62..64 строки)
<% @customer.accounts.each do |ac| %>
<div class="sl-item">
<div class="sl-left"> <img src="<%= ac.user.profile_picture %>" alt="user" class="img-circle" /> </div>
Как я могу это исправить?