gpt4 book ai didi

ruby-on-rails - 从 Heroku 迁移到专用服务器后,rails 生成蜻蜓为 # nike

站点已从 Heroku 迁移到专用的 Ubuntu 服务器,迁移站点正常工作后,除了托管在 S3 上的图像。

加载带有图像的页面时,将返回以下类型的错误:

Completed 200 OK in 1428.8ms (Views: 505.5ms | ActiveRecord: 322.2ms)
Started GET "/system/images/W1siZiIsIjIwMTYvMDkvMjIvMTMvMjQvMjUvMjE1L05hb21pX1NhbnNvbS5qcGciXSxbInAiLCJ0aHVtYiIsIjM2MHgzNjAjIl1d/picture.jpg" for ip at 2016-11-23 00:27:24 +0000

Dragonfly::Configurable::NotConfigured (You need to configure Dragonfly::DataStorage::S3DataStore with bucket_name):

我可以看到该应用程序没有在 gemfile 中列出蜻蜓,因为 Heroku 似乎做的事情有点不同,并且已经重新安装了蜻蜓,但是当尝试生成配置文件时返回以下错误。
# rails generate dragonfly
appdir/config/initializers/recaptcha.rb:2:in `block in <top (required)>': undefined method `public_key=' for #<Recaptcha::Configuration:0x0000000521f070> (NoMethodError)
from appdir/vendor/bundle/ruby/2.0.0/gems/recaptcha-4.0.0/lib/recaptcha.rb:30:in `configure'
from appdir/config/initializers/recaptcha.rb:1:in `<top (required)>'
from appdir/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:245:in `load'
from appdir/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:245:in `block in load'
from appdir/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:236:in `load_dependency'
from appdir/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:245:in `load'
from appdir/vendor/bundle/ruby/2.0.0/gems/railties-3.2.18/lib/rails/engine.rb:593:in `block (2 levels) in <class:Engine>'
from appdir/vendor/bundle/ruby/2.0.0/gems/railties-3.2.18/lib/rails/engine.rb:592:in `each'
from appdir/vendor/bundle/ruby/2.0.0/gems/railties-3.2.18/lib/rails/engine.rb:592:in `block in <class:Engine>'
from appdir/vendor/bundle/ruby/2.0.0/gems/railties-3.2.18/lib/rails/initializable.rb:30:in `instance_exec'
from appdir/vendor/bundle/ruby/2.0.0/gems/railties-3.2.18/lib/rails/initializable.rb:30:in `run'
from appdir/vendor/bundle/ruby/2.0.0/gems/railties-3.2.18/lib/rails/initializable.rb:55:in `block in run_initializers'
from appdir/vendor/bundle/ruby/2.0.0/gems/railties-3.2.18/lib/rails/initializable.rb:54:in `each'
from appdir/vendor/bundle/ruby/2.0.0/gems/railties-3.2.18/lib/rails/initializable.rb:54:in `run_initializers'
from appdir/vendor/bundle/ruby/2.0.0/gems/railties-3.2.18/lib/rails/application.rb:136:in `initialize!'
from appdir/vendor/bundle/ruby/2.0.0/gems/railties-3.2.18/lib/rails/railtie/configurable.rb:30:in `method_missing'
from appdir/config/environment.rb:5:in `<top (required)>'
from appdir/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:251:in `require'
from appdir/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:251:in `block in require'
from appdir/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:236:in `load_dependency'
from appdir/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:251:in `require'
from appdir/vendor/bundle/ruby/2.0.0/gems/railties-3.2.18/lib/rails/application.rb:103:in `require_environment!'
from appdir/vendor/bundle/ruby/2.0.0/gems/railties-3.2.18/lib/rails/commands.rb:25:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

Recaptcha 本身似乎工作正常,并且 bundle install 没有返回任何错误,但我无法让蜻蜓工作。

recaptcha.rb 看起来像这样
Recaptcha.configure do |config|
config.public_key = 'public key'
config.private_key = 'private key'
config.api_version = 'v2'
end

我创建了不存在的 .env 文件,内容如下:
export RECAPTCHA_PUBLIC_KEY = 'public key'
export RECAPTCHA_PRIVATE_KEY = 'private key'

我还尝试手动添加到 config/environments/production.rb 和 config/environments/development.rb 如下:
recaptcha_public_key= "[PUBLIC KEY]"
recaptcha_private_key= "[PRIVATE KEY]"

我不确定我在这里缺少什么,从 Heroku 迁移到独立的 Linux 系统后,是否有人对蜻蜓和 recaptcha 有任何经验

最佳答案

他们在版本 4 中更改了 API,因此如果您通过 gemfile 安装它而不指定版本并且默认为版本 4,则需要在配置中进行更改。

从他们的 CHANGELOG.md :

4.0.0 - 2016-11-14

public_key -> site_key and private_key -> secret_key

更改您的 config/initializers/recaptcha.rb对此:

Recaptcha.configure do |config|
config.site_key = 'public key'
config.secret_key = 'private key'
...

关于ruby-on-rails - 从 Heroku 迁移到专用服务器后,rails 生成蜻蜓为 #<Recaptcha 返回未定义的方法 `public_key=',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40824571/

26 4 0
文章推荐: Docker - Prometheus 容器立即死亡
文章推荐: php - 将特殊字符转换为 HTML 实体
文章推荐: php - 如何从服务器删除文件
文章推荐: php - Opencart如何测试模块是否安装?
行者123
个人简介

我是一名优秀的程序员,十分优秀!

滴滴打车优惠券免费领取
滴滴打车优惠券
全站热门文章
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com