我甚至不知道从哪里开始......一直试图弄清楚这一点。谷歌没有任何相关内容。我以前很好,整个网站都无法使用。我去的任何页面都会抛出错误"无法将未经许可的参数转换为哈希"
宝石向我展示的更好的错误:
attr_reader :cause
def initialize(template)
super($!.message)
set_backtrace($!.backtrace)
@cause = $!
@template, @sub_templates = template, nil
end
我当天早些时候已经升级到Rails 5,与其他Rails应用完全相同,并且没有任何问题 - 它们都使用或多或少相同的宝石。我可能会遗漏一些东西,但我甚至无法找到导致这种情况的最轻微线索。任何帮助都会很棒!谢谢!如果您需要其他任何内容,请与我们联系。
的Gemfile:
source 'https://rubygems.org'
ruby '2.4.1'
gem 'rails', '>= 5.0.0.rc2', '< 5.1'
gem 'bootstrap-sass', '~> 3.3', '>= 3.3.6'
gem 'sass-rails', '~> 5.0', '>= 5.0.5'
gem 'therubyracer', '~> 0.12.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails'
gem 'jquery-rails'
gem 'jbuilder'
gem 'sdoc', '0.4.0', group: :doc
gem 'animate-rails'
gem 'google-analytics-rails', '1.1.0'
gem 'font-awesome-rails'
gem 'high_voltage', '~> 3.0.0'
gem 'sprockets-rails', require: 'sprockets/railtie'
gem 'simple_form'
gem 'pg', '~> 0.20.0'
gem 'canonical-rails', github: 'jumph4x/canonical-rails'
gem 'sitemap_generator'
gem 'fog'
gem 'listen', '~> 3.0'
gem 'devise', '~> 4.2'
gem 'paperclip'
gem 'aws-sdk', '~> 2.3'
gem 'wicked'
gem 'reform'
gem 'reform-rails'
gem 'binding_of_caller'
gem 'bootstrap-datepicker-rails'
gem 'exception_notification'
gem 'jquery-tablesorter'
gem 'friendly_id', '~> 5.1.0'
gem 'will_paginate', '~> 3.1.0'
gem 'sidekiq'
gem 'redis'
gem 'twilio-ruby'
gem 'phony_rails'
gem 'social-share-button'
gem 'chosen-rails'
gem 'respond-js-rails'
group :development, :test do
gem 'byebug'
gem 'better_errors'
gem 'letter_opener'
gem 'dotenv-rails'
gem 'rspec-rails'
gem 'factory_girl_rails'
end
group :development do
gem 'spring'
gem 'web-console'
end
group :test do
gem 'minitest-reporters', '1.0.5'
gem 'mini_backtrace', '0.1.3'
gem 'guard-minitest', '2.3.1'
gem 'faker'
gem 'capybara'
gem 'guard-rspec'
gem 'launchy'
end
group :production do
gem 'rails_12factor', '~> 0.0.3'
gem 'puma', '~> 3.8.2'
gem 'heroku-deflater'
end
gem 'redactor-rails', github: 'glyph-fr/redactor-rails'
错误日志的相关部分:
actionpack (5.1.0.rc2) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.1.0.rc2) lib/action_dispatch/middleware/static.rb:125:in `call'
() Users/luisaczc/.rvm/gems/ruby-2.4.1@global/gems/rack- 2.0.1/lib/rack/sendfile.rb:111:in `call'
railties (5.1.0.rc2) lib/rails/engine.rb:522:in `call'
puma (3.8.2) lib/puma/configuration.rb:224:in `call'
puma (3.8.2) lib/puma/server.rb:600:in `handle_request'
puma (3.8.2) lib/puma/server.rb:435:in `process_client'
puma (3.8.2) lib/puma/server.rb:299:in `block in run'
puma (3.8.2) lib/puma/thread_pool.rb:120:in `block in spawn_thread'
ActionView::Template::Error - unable to convert unpermitted parameters to hash:
actionview (5.1.0.rc2) lib/action_view/template/error.rb:67:in `initialize'
actionview (5.1.0.rc2) lib/action_view/template.rb:321:in `handle_render_error'
actionview (5.1.0.rc2) lib/action_view/template.rb:160:in `rescue in render'
actionview (5.1.0.rc2) lib/action_view/template.rb:155:in `render'
actionview (5.1.0.rc2) lib/action_view/renderer/template_renderer.rb:64:in `render_with_layout'
actionview (5.1.0.rc2) lib/action_view/renderer/template_renderer.rb:50:in `render_template'
actionview (5.1.0.rc2) lib/action_view/renderer/template_renderer.rb:14:in `render'
actionview (5.1.0.rc2) lib/action_view/renderer/renderer.rb:42:in `render_template'
actionview (5.1.0.rc2) lib/action_view/renderer/renderer.rb:23:in `render'
actionview (5.1.0.rc2) lib/action_view/rendering.rb:103:in `_render_template'
actionpack (5.1.0.rc2) lib/action_controller/metal/streaming.rb:217:in `_render_template'
actionview (5.1.0.rc2) lib/action_view/rendering.rb:83:in `render_to_body'
actionpack (5.1.0.rc2) lib/action_controller/metal/rendering.rb:52:in `render_to_body'
actionpack (5.1.0.rc2) lib/action_controller/metal/renderers.rb:141:in `render_to_body'
actionpack (5.1.0.rc2) lib/abstract_controller/rendering.rb:24:in `render'
actionpack (5.1.0.rc2) lib/action_controller/metal/rendering.rb:36:in `render'
actionpack (5.1.0.rc2) lib/action_controller/metal/instrumentation.rb:44:in `block (2 levels) in render'
重申一下 - 这不是页面特定的,它贯穿始终。通常我可以跟随控制器等并解决问题,但我完全失去了这个。
答案 0 :(得分:39)
在rails 5.1中,如果要将params对象转换为哈希值,则必须允许访问参数。
AFAIK有两种解决方案:
1)在您的控制器中执行以下操作:
form = Form.new(params[:form].permit!)
2)将它添加到你的config / application.rb中以禁用rails中的强参数(通常不建议):
config.action_controller.permit_all_parameters = true
答案 1 :(得分:0)
通过大量搜索,我发现它是一个宝石,在将Rails更新为5.1后导致错误。使用&#39; canonical-rails&#39;宝石并使用该行&lt;%= canonical_tag - %&gt;由于某种原因造成了这个错误。无法告诉你为什么,但希望这会帮助遇到它的任何人。
答案 2 :(得分:0)
如果你降级到5.0(&lt; 5.1),可能会更容易调试,因为你会看到弃用警告而不是异常。