ActionView::TemplateError (protected method filter_parameters called for #)
Posted by alex in Insights at 1:41 AMI assisted in looking into a Rails issue earlier with a friend. After making some modifications to some Ruby code he had an issue receiving exception emails which were generated by Rails. The rails plugin being used to accomplish this is called exception_notification and resolving the problem was simple. As you will see below instead of upgrading the entire plugin a couple lines in one ruby file were modified, the web server restarted, and the exceptions again started functioning properly. Below I display more of the error and the modifications made to resolve the error.
Production Log Error: ActionView::TemplateError (protected method filter_parameters called for #)
Detailed Production Log Error:
ActionView::TemplateError (protected method `filter_parameters' called for #<MgmtQueriesController:0xb70cd750>) on line #3 of vendor
/plugins/exception_notification/views/exception_notifier/_request.rhtml:
1: * URL : <%= @request.protocol %><%= @host %><%= @request.request_uri %>
2: * IP address: <%= @request.env["HTTP_X_FORWARDED_FOR"] || @request.env["REMOTE_ADDR"] %>
3: * Parameters: <%= filter_sensitive_post_data_parameters(@request.parameters).inspect %>
4: * Rails root: <%= @rails_root %>
vendor/plugins/exception_notification/lib/exception_notifier_helper.rb:70:in `filter_sensitive_post_data_parameters'
vendor/plugins/exception_notification/views/exception_notifier/_request.rhtml:3:in `_run_erb_47vendor47plugins47exception_notifi
cation47views47exception_notifier47_request46rhtml'
vendor/rails/actionpack/lib/action_view/base.rb:338:in `send'
vendor/rails/actionpack/lib/action_view/base.rb:338:in `execute'
vendor/rails/actionpack/lib/action_view/template_handlers/compilable.rb:29:in `send'
vendor/rails/actionpack/lib/action_view/template_handlers/compilable.rb:29:in `render'
vendor/rails/actionpack/lib/action_view/template.rb:35:in `render'
vendor/rails/actionpack/lib/action_view/template.rb:22:in `render_template'
vendor/rails/actionpack/lib/action_view/base.rb:245:in `render_file'
vendor/rails/actionpack/lib/action_view/base.rb:269:in `render'
vendor/plugins/exception_notification/lib/exception_notifier_helper.rb:41:in `render_overridable'
vendor/plugins/exception_notification/lib/exception_notifier_helper.rb:30:in `render_section'
vendor/plugins/exception_notification/views/exception_notifier/exception_notification.rhtml:6:in `_run_erb_47vendor47plugins47ex
ception_notification47views47exception_notifier47exception_notification46rhtml'
vendor/plugins/exception_notification/views/exception_notifier/exception_notification.rhtml:6:in `map'
vendor/plugins/exception_notification/views/exception_notifier/exception_notification.rhtml:6:in `_run_erb_47vendor47plugins47ex
ception_notification47views47exception_notifier47exception_notification46rhtml'
vendor/rails/actionpack/lib/action_view/base.rb:338:in `send'
vendor/rails/actionpack/lib/action_view/base.rb:338:in `execute'
vendor/rails/actionpack/lib/action_view/template_handlers/compilable.rb:29:in `send'
vendor/rails/actionpack/lib/action_view/template_handlers/compilable.rb:29:in `render'
vendor/rails/actionpack/lib/action_view/template.rb:35:in `render'
vendor/rails/actionpack/lib/action_view/template.rb:22:in `render_template'
vendor/rails/actionpack/lib/action_view/base.rb:245:in `render_file'
vendor/rails/actionpack/lib/action_view/base.rb:269:in `render'
vendor/rails/actionmailer/lib/action_mailer/base.rb:541:in `render'
vendor/plugins/exception_notification/views/exception_notifier/exception_notification.rhtml:6:in `_run_erb_47vendor47plugins47ex
ception_notification47views47exception_notifier47exception_notification46rhtml'
vendor/plugins/exception_notification/views/exception_notifier/exception_notification.rhtml:6:in `map'
vendor/plugins/exception_notification/views/exception_notifier/exception_notification.rhtml:6:in `_run_erb_47vendor47plugins47ex
ception_notification47views47exception_notifier47exception_notification46rhtml'
vendor/rails/actionpack/lib/action_view/base.rb:338:in `send'
vendor/rails/actionpack/lib/action_view/base.rb:338:in `execute'
vendor/rails/actionpack/lib/action_view/template_handlers/compilable.rb:29:in `send'
vendor/rails/actionpack/lib/action_view/template_handlers/compilable.rb:29:in `render'
vendor/rails/actionpack/lib/action_view/template.rb:35:in `render'
vendor/rails/actionpack/lib/action_view/template.rb:22:in `render_template'
vendor/rails/actionpack/lib/action_view/base.rb:245:in `render_file'
vendor/rails/actionpack/lib/action_view/base.rb:269:in `render'
vendor/rails/actionmailer/lib/action_mailer/base.rb:541:in `render'
vendor/rails/actionmailer/lib/action_mailer/base.rb:533:in `render_message'
vendor/rails/actionmailer/lib/action_mailer/base.rb:478:in `create!'
vendor/rails/actionmailer/lib/action_mailer/base.rb:439:in `initialize'
vendor/rails/actionmailer/lib/action_mailer/base.rb:383:in `new'
vendor/rails/actionmailer/lib/action_mailer/base.rb:383:in `method_missing'
vendor/plugins/exception_notification/lib/exception_notifiable.rb:95:in `rescue_action_in_public'
vendor/rails/actionpack/lib/action_controller/rescue.rb:127:in `rescue_action'
vendor/rails/actionpack/lib/action_controller/rescue.rb:203:in `perform_action_without_caching'
vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:13:in `perform_action'
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:33:in `cache'
vendor/rails/activerecord/lib/active_record/query_cache.rb:8:in `cache'
vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:12:in `perform_action'
vendor/rails/actionpack/lib/action_controller/base.rb:529:in `send'
vendor/rails/actionpack/lib/action_controller/base.rb:529:in `process_without_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:569:in `process_without_session_management_support'
vendor/rails/actionpack/lib/action_controller/session_management.rb:130:in `process'
vendor/rails/actionpack/lib/action_controller/base.rb:389:in `process'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:149:in `handle_request'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:107:in `dispatch'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:104:in `synchronize'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:104:in `dispatch'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:120:in `dispatch_cgi'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:35:in `dispatch'
/var/lsws/fcgi-bin/RailsRunner.rb:98
Rails Exception Notification Plugin Error Details:
If you receive a similar error it more than likely means that you need to upgrade the Rails exception_notification plugin. It appears that this error typically is associated with upgrading Rails to 2.1 and not upgrading the exception notification plugin however in this case Rails had been upgraded to version 2.1 long ago and the exception notification plugin had been working fine for some time so I am not sure specifically why this is the case but instead I only know how to resolve the issue.
Resolve Rails Exception Notification Plugin Error:
To resolve the error you will need to modify the exception_notifier_helper.rb located from the root of your Ruby project in the “vendor/plugins/exception_notification/lib/” directory. The modifications will be made to line 70 and line 76 of the file.
Modify Line 70 Of exception_notifier_helper.rb:
-exclude_raw_post_parameters? ? @controller.filter_parameters(parameters) : parameters +exclude_raw_post_parameters? ? @controller.send!(:filter_parameters, parameters) : parameters
Modify Line 76 Of exception_notifier_helper.rb:
-return @controller.filter_parameters({env_key => env_value}).values[0]
+return @controller.send!(:filter_parameters, {env_key => env_value}).values[0]
Complete View Of exception_notifier_helper.rb:
require 'pp'
# Copyright (c) 2005 Jamis Buck
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
module ExceptionNotifierHelper
VIEW_PATH = "views/exception_notifier"
APP_PATH = "#{RAILS_ROOT}/app/#{VIEW_PATH}"
PARAM_FILTER_REPLACEMENT = "[FILTERED]"
def render_section(section)
RAILS_DEFAULT_LOGGER.info("rendering section #{section.inspect}")
summary = render_overridable(section).strip
unless summary.blank?
title = render_overridable(:title, :locals => { :title => section }).strip
"#{title}nn#{summary.gsub(/^/, " ")}nn"
end
end
def render_overridable(partial, options={})
if File.exist?(path = "#{APP_PATH}/_#{partial}.rhtml")
render(options.merge(:file => path, :use_full_path => false))
elsif File.exist?(path = "#{File.dirname(__FILE__)}/../#{VIEW_PATH}/_#{partial}.rhtml")
render(options.merge(:file => path, :use_full_path => false))
else
""
end
end
def inspect_model_object(model, locals={})
render_overridable(:inspect_model,
:locals => { :inspect_model => model,
:show_instance_variables => true,
:show_attributes => true }.merge(locals))
end
def inspect_value(value)
len = 512
result = object_to_yaml(value).gsub(/n/, "n ").strip
result = result[0,len] + "... (#{result.length-len} bytes more)" if result.length > len+20
result
end
def object_to_yaml(object)
object.to_yaml.sub(/^---s*/m, "")
end
def exclude_raw_post_parameters?
@controller && @controller.respond_to?(:filter_parameters)
end
def filter_sensitive_post_data_parameters(parameters)
exclude_raw_post_parameters? ? @controller.send!(:filter_parameters, parameters) : parameters
end
def filter_sensitive_post_data_from_env(env_key, env_value)
return env_value unless exclude_raw_post_parameters?
return PARAM_FILTER_REPLACEMENT if (env_key =~ /RAW_POST_DATA/i)
return @controller.send!(:filter_parameters, {env_key => env_value}).values[0]
end
end
I located the update from this Project URL at Github. After making the changes to the file restart your web server and verify that everything is functioning properly again.
|
|
|
|
Related posts:
- MySQL error (undefined method `each) with Rails 2.2.x rake aborted! undefined method `each' for #<Mysql:0x5cdda84> Realized from this...
- Cisco IOS: Forward Called Teclo DID To An Extension, Translate, Translation-Rule Limitation A client of mine had a Cisco 2811 installed before...
- Free method to convert Word files (.doc, .docx) to pdf A quick and easy way to convert Microsoft Word (.doc,...
- Improved Method to Batch Resize Images in Adobe Photoshop CS4 I recently wrote an article on how to batch resize...
- Download Youtube Videos Using Firefox Add-On Called 1-Click Youtube Video Download Someone at work asked me today if I could download...











Entries (RSS)
I made the changes as you have suggested. But now getting the error ActionView::TemplateError (undefined method `send!’
[Reply]
alex Reply:
October 28th, 2010 at 1:12 PM
Hello San,
It sounds as if maybe you made the modification to line 70 and possibly not to line 76. Double check the changes made to line 70 and 76 to verify they are correct but if they are and you continue to have issues it sounds as if you may have something else wrong that is outside the scope of this article.
Thanks.
alex
[Reply]