bborn / communityengine

Adds basic social networking capabilities to your existing application, including users, blogs, photos, clippings, favorites, and more.
http://www.communityengine.org
Other
1.14k stars 317 forks source link

Config not clear when starting new project undefined method `public_key=' for #<Recaptcha::Configuration #331

Closed alexmc6 closed 3 years ago

alexmc6 commented 7 years ago

Firstly I am using the edge branch as I wanted the latest version of rails. Unfortunately my app was intended for rails v5. I had to downgrade the rails version in the Gemfile (and a few other things) down to 4.2

Now unfortunately I get this error on rake db:migrate. I assume it is due to poor configuration.

Alexs-MBP-2:socon-mockup alex$ bin/rake db:migrate
rake aborted!
NoMethodError: undefined method `public_key=' for #<Recaptcha::Configuration:0x007ff9a4608e48>
Did you mean?  public_send
/Users/alex/.rvm/gems/ruby-2.3.1@rails-devise-pundit/bundler/gems/communityengine-4e4eb79181f2/config/initializers/recaptcha_constants.rb:3:in `block in <top (required)>'
/Users/alex/.rvm/gems/ruby-2.3.1@rails-devise-pundit/gems/recaptcha-4.0.0/lib/recaptcha.rb:30:in `configure'
/Users/alex/.rvm/gems/ruby-2.3.1@rails-devise-pundit/bundler/gems/communityengine-4e4eb79181f2/config/initializers/recaptcha_constants.rb:2:in `<top (required)>'
/Users/alex/.rvm/gems/ruby-2.3.1@rails-devise-pundit/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:268:in `load'
/Users/alex/.rvm/gems/ruby-2.3.1@rails-devise-pundit/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:268:in `block in load'
/Users/alex/.rvm/gems/ruby-2.3.1@rails-devise-pundit/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:240:in `load_dependency'
/Users/alex/.rvm/gems/ruby-2.3.1@rails-devise-pundit/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:268:in `load'
/Users/alex/.rvm/gems/ruby-2.3.1@rails-devise-pundit/gems/railties-4.2.7.1/lib/rails/engine.rb:652:in `block in load_config_initializer'
/Users/alex/.rvm/gems/ruby-2.3.1@rails-devise-pundit/gems/activesupport-4.2.7.1/lib/active_support/notifications.rb:166:in `instrument'
/Users/alex/.rvm/gems/ruby-2.3.1@rails-devise-pundit/gems/railties-4.2.7.1/lib/rails/engine.rb:651:in `load_config_initializer'
/Users/alex/.rvm/gems/ruby-2.3.1@rails-devise-pundit/gems/railties-4.2.7.1/lib/rails/engine.rb:616:in `block (2 levels) in <class:Engine>'
/Users/alex/.rvm/gems/ruby-2.3.1@rails-devise-pundit/gems/railties-4.2.7.1/lib/rails/engine.rb:615:in `each'
/Users/alex/.rvm/gems/ruby-2.3.1@rails-devise-pundit/gems/railties-4.2.7.1/lib/rails/engine.rb:615:in `block in <class:Engine>'
/Users/alex/.rvm/gems/ruby-2.3.1@rails-devise-pundit/gems/railties-4.2.7.1/lib/rails/initializable.rb:30:in `instance_exec'
/Users/alex/.rvm/gems/ruby-2.3.1@rails-devise-pundit/gems/railties-4.2.7.1/lib/rails/initializable.rb:30:in `run'
/Users/alex/.rvm/gems/ruby-2.3.1@rails-devise-pundit/gems/railties-4.2.7.1/lib/rails/initializable.rb:55:in `block in run_initializers'
/Users/alex/.rvm/gems/ruby-2.3.1@rails-devise-pundit/gems/railties-4.2.7.1/lib/rails/initializable.rb:44:in `each'
/Users/alex/.rvm/gems/ruby-2.3.1@rails-devise-pundit/gems/railties-4.2.7.1/lib/rails/initializable.rb:44:in `tsort_each_child'
/Users/alex/.rvm/gems/ruby-2.3.1@rails-devise-pundit/gems/railties-4.2.7.1/lib/rails/initializable.rb:54:in `run_initializers'
/Users/alex/.rvm/gems/ruby-2.3.1@rails-devise-pundit/gems/railties-4.2.7.1/lib/rails/application.rb:352:in `initialize!'
/Users/alex/projects/ruby/socon-mockup/config/environment.rb:5:in `<top (required)>'
/Users/alex/.rvm/gems/ruby-2.3.1@rails-devise-pundit/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:274:in `require'
/Users/alex/.rvm/gems/ruby-2.3.1@rails-devise-pundit/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:274:in `block in require'
/Users/alex/.rvm/gems/ruby-2.3.1@rails-devise-pundit/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:240:in `load_dependency'
/Users/alex/.rvm/gems/ruby-2.3.1@rails-devise-pundit/gems/activesupport-4.2.7.1/lib/active_support/dependencies.rb:274:in `require'
/Users/alex/.rvm/gems/ruby-2.3.1@rails-devise-pundit/gems/railties-4.2.7.1/lib/rails/application.rb:328:in `require_environment!'
/Users/alex/.rvm/gems/ruby-2.3.1@rails-devise-pundit/gems/railties-4.2.7.1/lib/rails/application.rb:457:in `block in run_tasks_blocks'
/Users/alex/.rvm/gems/ruby-2.3.1@rails-devise-pundit/gems/rake-11.3.0/exe/rake:27:in `<top (required)>'
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)
Alexs-MBP-2:socon-mockup alex$

So - I dont know whether recaptcha is really optional. This is what my config/application_config.rb looks like. I would appreciate it if someone can give me their working version.

configatron.configure_from_hash(
  :community_name => "Socon",

  # It seems like Recaptcha is enabled by default - so it needs to be set up
  :allow_anonymous_commenting => false,
  :allow_anonymous_forum_posting => false,
  :require_captcha_on_signup => false,

  :recaptcha_pub_key => '6LcYIw0UAAAAAE9_GNKtxKdqTa6SjIglpip3ijzQ',
  :recaptcha_priv_key => 'XXXXXREDACTEDXXXXX'

  #You can also require ReCaptcha on signup (to prevent automated signups) by adding this in your application_config.rb (you'll still need to add your ReCaptcha keys):
  # :require_captcha_on_signup => true
)

Any suggestions (or any info I should be supplying to help diagnose the problem?)

rmccown commented 7 years ago

I'm also having this same issue, with a clean, newly generated app

nikhilthombare commented 7 years ago

Yes I had same issue when I run rake db:migrate its give me same error. My rails -v ( 4.1.0 ) and ruby -v ( 2.0.0 ). Can anyone have solution for that issue?

patilswapnil commented 7 years ago

Hello,

This problem lies in recaptcha gem. They have recently renamed public_key -> site_key and private_key -> secret_key

see the configuration file https://github.com/ambethia/recaptcha/blob/56679316e7731b596c3089768cad8021c8170cce/lib/recaptcha/configuration.rb

if you change ..gems/community_engine-3.2.0/config/initializers/recaptcha_constants.rb file to reflect new constants it will work.

HTH.