N + 1 обнаружено, что это значит, что я должен сделать, чтобы заставить его работать.Уменьшить N + 1 Запросы
Я использую Пули камень для показа N + 1 запросов
user: kalyan
N+1 Query detected
Emp => [:functions]
Add to your finder: :include => [:functions]
N+1 Query method call stack
/home/Documents/app/views/tics/show.html.haml:20:in `_app_views_tics_show_html_haml___2301551533476719406_237290860'
Это сообщение от пули камень.
_app_views_tics_show.html.haml
- if (@tic.assigned_to == current_user.emp) or (current_user.emp_functions.map{|x| x.id}.include?(1) if current_user.emp_functions.present?)
= best_in_place @tic, :subject
- else
= @tic.subject
помочь мне уменьшить проблему п + 1 запрос
emp.rb
has_many :emp_functions, inverse_of: :emp,dependent: :restrict_with_exception
belongs_to: пользователь, inverse_of:: emp
emp_functions.rb
belongs_to :emp , inverse_of: :emp_functions
belongs_to :function
function.rb
has_many :emp_functions, dependent: :restrict_with_exception
has_many :emp, through: :emp_functions
user.rb
has_one :emp, inverse_of: :user, dependent: :restrict_with_exception
sem-related - http://stackoverflow.com/a/26251892/525478 –