I am using Rails 5.2.2 . I installed the Bullet Gem and getting this on 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'
According to the guide i added includes(:user)
to my account.rb
file. I tried to add it to index action and show action both but this alert comes in again and again.
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 (customers 62..64 lines)
<% @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>
How can i fix that?
views/customers/show.html.erb
. The error cause in line 64 (look at the error stacktrace), so please add code block, containing this line. – Quaternary