英文:
Ruby on Rails + Psych::DisallowedClass in PostsController#show
问题
以下是Gemfile中的部分内容的翻译:
source 'https://rubygems.org'
ruby '2.7.1'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
# 我安装的 gems
gem 'aws-sdk-s3'
gem 'bootsnap', require: false
gem 'simple_form'
gem 'friendly_id', '~> 5.1.0'
gem 'devise'
gem 'will_paginate', '~> 3.1.0'
gem 'meta-tags'
gem 'omniauth'
gem "omniauth-rails_csrf_protection", "~> 1.0"
gem 'omniauth-twitter'
gem 'impressionist', '~>1.6.1'
gem 'gibbon'
gem 'acts_as_votable', '~> 0.11.1'
gem 'awesome_print'
gem 'sanitize'
gem "mini_magick"
gem "redcarpet"
gem 'file_validators'
gem 'pg_search'
gem 'invisible_captcha'
gem "recaptcha"
# 使用 edge Rails 替代:gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2'
# 使用 sqlite3 作为 Active Record 的数据库
gem 'pg'
# 使用 Puma 作为应用服务器
gem 'puma', '~> 3.7'
# 使用 SCSS 作为样式表
gem 'sass-rails', '~> 5.0'
# 使用 Uglifier 作为 JavaScript 资源的压缩器
gem 'uglifier', '>= 1.3.0'
# 有关更多支持的运行时,请参见 https://github.com/rails/execjs#readme
# gem 'therubyracer', platforms: :ruby
# 使用 CoffeeScript 处理 .coffee 资源和视图
gem 'coffee-rails', '~> 4.2'
# Turbolinks 让你的 Web 应用程序导航更快。了解更多:https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# 使用 Jbuilder 构建 JSON API
gem 'jbuilder', '~> 2.5'
# 在生产中使用 Redis 适配器运行 Action Cable
# gem 'redis', '~> 3.0'
# 使用 ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# 使用 Capistrano 进行部署
# gem 'capistrano-rails', group: :development
group :development, :test do
# 在代码中的任何位置调用 'byebug' 都可以停止执行并获取调试器控制台
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
# 添加对 Capybara 系统测试和 selenium 驱动程序的支持
gem 'capybara', '~> 2.13'
gem 'selenium-webdriver'
end
group :development do
# 在异常页面上或在代码中的任何位置使用 '<%= console %>' 来访问 IRB 控制台
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
# Spring 通过在后台运行应用程序来加速开发。了解更多:https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
# Windows 不包括 zoneinfo 文件,因此请捆绑 tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'mina'
gem 'elasticsearch-model'
gem 'elasticsearch-rails'
请注意,翻译中保留了Gemfile中的代码和注释,并仅对注释进行了翻译。
英文:
Never seen this error before. I wonder if it is about the RoR env setup than my codes.
btw why is it even "klassname", should it not be with c "classname"
My Gemfile
source 'https://rubygems.org'
ruby '2.7.1'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
# gems I installed
gem 'aws-sdk-s3'
gem 'bootsnap', require: false
gem 'simple_form'
gem 'friendly_id', '~> 5.1.0'
gem 'devise'
gem 'will_paginate', '~> 3.1.0'
gem 'meta-tags'
gem 'omniauth'
gem "omniauth-rails_csrf_protection", "~> 1.0"
gem 'omniauth-twitter'
gem 'impressionist', '~>1.6.1'
gem 'gibbon'
gem 'acts_as_votable', '~> 0.11.1'
gem 'awesome_print'
gem 'sanitize'
gem "mini_magick"
gem "redcarpet"
gem 'file_validators'
gem 'pg_search'
gem 'invisible_captcha'
gem "recaptcha"
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2'
# Use sqlite3 as the database for Active Record
gem 'pg'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '~> 2.13'
gem 'selenium-webdriver'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'mina'
gem 'elasticsearch-model'
gem 'elasticsearch-rails'
答案1
得分: 1
我认为问题出在Psych gem版本
上。
你可以尝试在application.rb
中添加这一行:
config.active_record.yaml_column_permitted_classes = [Symbol, Hash, Array, ActiveSupport::HashWithIndifferentAccess]
英文:
I think the issue is with Psych gem version
.
You can try adding this line application.rb
config.active_record.yaml_column_permitted_classes = [Symbol, Hash, Array, ActiveSupport::HashWithIndifferentAccess]
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论