我想为我的应用程序安装 activeadmin gem,但是当我将它写入我的 gemfile 时:
gem 'activeadmin' gem "meta_search"
当 rails s 出现错误时,如果我从我的 gemfile 中删除 simplecaptcha 一切正常,那么 simplecaptcha 和 activeadmins formtastic gems 有问题,如何解决?
这是我的 gemfile:
source 'https://rubygems.org'
gem 'rails', '3.2.6'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql2'
#gem 'haml'
gem 'haml-rails'
gem 'kaminari'
gem "galetahub-simple_captcha", :require => "simple_captcha"
gem "authlogic"
gem "rails3-generators"
gem 'activeadmin'
gem "meta_search"
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'debugger'
和错误:
rails s
=> Booting WEBrick
=> Rails 3.2.6 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /media/_Projects/Amis/config/environment.rb:5)
Exiting
/home/pavel/.rvm/gems/ruby-1.9.3-p194/gems/galetahub-simple_captcha-0.1.3/lib/simple_captcha/formtastic.rb:2:in `<module:SimpleCaptcha>': uninitialized constant Formtastic::SemanticFormBuilder (NameError)
from /home/pavel/.rvm/gems/ruby-1.9.3-p194/gems/galetahub-simple_captcha-0.1.3/lib/simple_captcha/formtastic.rb:1:in `<top (required)>'
from /home/pavel/.rvm/gems/ruby-1.9.3-p194/gems/galetahub-simple_captcha-0.1.3/lib/simple_captcha/engine.rb:19:in `block in <class:Engine>'
from /home/pavel/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.6/lib/active_support/lazy_load_hooks.rb:34:in `call'
from /home/pavel/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.6/lib/active_support/lazy_load_hooks.rb:34:in `execute_hook'
from /home/pavel/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.6/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
from /home/pavel/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.6/lib/active_support/lazy_load_hooks.rb:42:in `each'
from /home/pavel/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.6/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
from /home/pavel/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.6/lib/rails/application/finisher.rb:59:in `block in <module:Finisher>'
from /home/pavel/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.6/lib/rails/initializable.rb:30:in `instance_exec'
from /home/pavel/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.6/lib/rails/initializable.rb:30:in `run'
from /home/pavel/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.6/lib/rails/initializable.rb:55:in `block in run_initializers'
from /home/pavel/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.6/lib/rails/initializable.rb:54:in `each'
from /home/pavel/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.6/lib/rails/initializable.rb:54:in `run_initializers'
from /home/pavel/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.6/lib/rails/application.rb:136:in `initialize!'
from /home/pavel/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.6/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /media/_Projects/Amis/config/environment.rb:5:in `<top (required)>'
from /media/_Projects/Amis/config.ru:4:in `block in <main>'
from /home/pavel/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
from /home/pavel/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
from /media/_Projects/Amis/config.ru:1:in `new'
from /media/_Projects/Amis/config.ru:1:in `<main>'
from /home/pavel/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/builder.rb:40:in `eval'
from /home/pavel/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/builder.rb:40:in `parse_file'
from /home/pavel/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/server.rb:200:in `app'
from /home/pavel/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.6/lib/rails/commands/server.rb:46:in `app'
from /home/pavel/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/server.rb:301:in `wrapped_app'
from /home/pavel/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/server.rb:252:in `start'
from /home/pavel/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.6/lib/rails/commands/server.rb:70:in `start'
from /home/pavel/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.6/lib/rails/commands.rb:55:in `block in <top (required)>'
from /home/pavel/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.6/lib/rails/commands.rb:50:in `tap'
from /home/pavel/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.6/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
最佳答案
galetahub-simple_captcha
已过时,因为它使用旧的 formtastic 构建器类 (Formtastic::SemanticFormBuilder
),该类在最近的 formtastic 版本中不再存在。您有以下选择:
- 使用另一个 gem 作为验证码
- 使用旧版本的 formtastic
- monkey 在 initalizer 中修补验证码 gem
我会推荐 1. 因为这个 gem 看起来很旧而且已经将近一年没有更新了。我不会推荐 2. 因为 activeadmin 也依赖于 formtastic。我不会推荐 3. 因为你不知道还有什么坏了。
关于ruby-on-rails - SimpleCaptcha 和 Formtastic 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12043253/