未定义的局部变量或方法“newrelic_ignore_enduser”
undefined local variable or method `newrelic_ignore_enduser'
New Relic 文档说:
为了防止控制器中所有操作的页面加载时间(有时称为真实用户监控或 RUM),向控制器添加这样的调用 class:
newrelic_ignore_enduser
我如下添加了对newrelic_ignore_enduser
的调用,得到了错误undefined local variable or method 'newrelic_ignore_enduser'
。
books_controller.rb
class BooksController < ApplicationController
require 'newrelic_rpm'
...
def show
newrelic_ignore_enduser
end
...
end
Gemfile
gem 'newrelic_rpm', '~> 3.9.9.275'
问题:我需要做什么(require
可能是什么?)才能调用此方法?
更新
糟糕!我之前只在 production
组的 Gemfile
中包含了 newrelic_rpm
。我现在已将它添加到 group :development, :production do
,这很有帮助。我必须做的第二件事是从 class
级别(如所选答案所示)将方法称为 newrelic_ignore_enduser only: :show
,而不是像我最初尝试的那样从操作中调用。请注意,理想情况下,我更愿意根据条件从操作中调用此方法。
我认为你应该使用 newrelic_ignore_enduser
如下
class BooksController < ApplicationController
newrelic_ignore_enduser only: :show
...
end
New Relic 文档说:
为了防止控制器中所有操作的页面加载时间(有时称为真实用户监控或 RUM),向控制器添加这样的调用 class:
newrelic_ignore_enduser
我如下添加了对newrelic_ignore_enduser
的调用,得到了错误undefined local variable or method 'newrelic_ignore_enduser'
。
books_controller.rb
class BooksController < ApplicationController
require 'newrelic_rpm'
...
def show
newrelic_ignore_enduser
end
...
end
Gemfile
gem 'newrelic_rpm', '~> 3.9.9.275'
问题:我需要做什么(require
可能是什么?)才能调用此方法?
更新
糟糕!我之前只在 production
组的 Gemfile
中包含了 newrelic_rpm
。我现在已将它添加到 group :development, :production do
,这很有帮助。我必须做的第二件事是从 class
级别(如所选答案所示)将方法称为 newrelic_ignore_enduser only: :show
,而不是像我最初尝试的那样从操作中调用。请注意,理想情况下,我更愿意根据条件从操作中调用此方法。
我认为你应该使用 newrelic_ignore_enduser
如下
class BooksController < ApplicationController
newrelic_ignore_enduser only: :show
...
end