Site has been migrated from Heroku to a dedicated Ubuntu server, and after the migration site is working normally, except for the images which are on hosted on S3.
When loading pages with images on it, following type of error would be returned:
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):
I can see that application didn't have dragonfly listed in gemfile,as Heroku seems to do things a little differently, and have reinstalled dragonfly, but when trying to generate a configuration file following error is returned.
# 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 itself seems to be working fine, and bundle install didn't return any errors, but I can't get dragonfly to work.
recaptcha.rb looks like this
Recaptcha.configure do |config|
config.public_key = 'public key'
config.private_key = 'private key'
config.api_version = 'v2'
end
I have created .env file which didn't exist, with following content:
export RECAPTCHA_PUBLIC_KEY = 'public key'
export RECAPTCHA_PRIVATE_KEY = 'private key'
I also tried manually adding to config/environments/production.rb, and config/environments/development.rb following:
recaptcha_public_key= "[PUBLIC KEY]"
recaptcha_private_key= "[PRIVATE KEY]"
I am not sure what I a missing here, does anybody have any experience with dragonfly and recaptcha after migrating from Heroku to standalone Linux system
They changed the API with version 4, so if you're installing it through the gemfile without specifying version and it defaults to version 4, you'll need to make changes in your config.
From their CHANGELOG.md:
4.0.0 - 2016-11-14
public_key -> site_key and private_key -> secret_key
Change your config/initializers/recaptcha.rb
to this:
Recaptcha.configure do |config|
config.site_key = 'public key'
config.secret_key = 'private key'
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With