被这个问题折腾了很久,给回复表单加验证码功能,使用 simple_captcha。
按照https://github.com/galetahub/simple-captcha说明来操作的
gem 'simple_captcha', :git => 'git://github.com/galetahub/simple-captcha.git'
bundle update
.......
Using simple_captcha (0.1.6) from git://github.com/galetahub/simple-captcha.git (at master)
Using sorcery (0.8.5)
Using turbolinks (2.2.1)
Using uglifier (2.5.0)
Your bundle is updated!
rails g simple_captcha
rake db:migrate
感觉到这里都很正常,启动服务(使用的 RubyMine),报错:
/Users/ShayneChow/.rvm/gems/ruby-2.0.0-p451/gems/bundler-1.5.3/lib/bundler/source/git.rb:179:in `rescue in load_spec_files': git://github.com/galetahub/simple-captcha.git (at master) is not yet checked out. Run `bundle install` first. (Bundler::GitError)
from /Users/ShayneChow/.rvm/gems/ruby-2.0.0-p451/gems/bundler-1.5.3/lib/bundler/source/git.rb:176:in `load_spec_files'
from /Users/ShayneChow/.rvm/gems/ruby-2.0.0-p451/gems/bundler-1.5.3/lib/bundler/source/path.rb:86:in `local_specs'
from /Users/ShayneChow/.rvm/gems/ruby-2.0.0-p451/gems/bundler-1.5.3/lib/bundler/source/git.rb:150:in `specs'
from /Users/ShayneChow/.rvm/gems/ruby-2.0.0-p451/gems/bundler-1.5.3/lib/bundler/lazy_specification.rb:53:in `__materialize__'
from /Users/ShayneChow/.rvm/gems/ruby-2.0.0-p451/gems/bundler-1.5.3/lib/bundler/spec_set.rb:88:in `block in materialize'
from /Users/ShayneChow/.rvm/gems/ruby-2.0.0-p451/gems/bundler-1.5.3/lib/bundler/spec_set.rb:85:in `map!'
from /Users/ShayneChow/.rvm/gems/ruby-2.0.0-p451/gems/bundler-1.5.3/lib/bundler/spec_set.rb:85:in `materialize'
from /Users/ShayneChow/.rvm/gems/ruby-2.0.0-p451/gems/bundler-1.5.3/lib/bundler/definition.rb:133:in `specs'
from /Users/ShayneChow/.rvm/gems/ruby-2.0.0-p451/gems/bundler-1.5.3/lib/bundler/definition.rb:178:in `specs_for'
from /Users/ShayneChow/.rvm/gems/ruby-2.0.0-p451/gems/bundler-1.5.3/lib/bundler/definition.rb:167:in `requested_specs'
from /Users/ShayneChow/.rvm/gems/ruby-2.0.0-p451/gems/bundler-1.5.3/lib/bundler/environment.rb:18:in `requested_specs'
from /Users/ShayneChow/.rvm/gems/ruby-2.0.0-p451/gems/bundler-1.5.3/lib/bundler/runtime.rb:13:in `setup'
from /Users/ShayneChow/.rvm/gems/ruby-2.0.0-p451/gems/bundler-1.5.3/lib/bundler.rb:119:in `setup'
from /Users/ShayneChow/.rvm/gems/ruby-2.0.0-p451/gems/bundler-1.5.3/lib/bundler/setup.rb:17:in `<top (required)>'
from /Users/ShayneChow/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:135:in `require'
from /Users/ShayneChow/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
from /Users/ShayneChow/.rvm/rubies/ruby-2.0.0-p451/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:144:in `require'
from /Users/ShayneChow/project/lexuan/config/boot.rb:4:in `<top (required)>'
from /Users/ShayneChow/project/lexuan/bin/rails:3:in `require_relative'
from /Users/ShayneChow/project/lexuan/bin/rails:3:in `<top (required)>'
from -e:1:in `load'
from -e:1:in `<main>'
Process finished with exit code 1
Mac OS X 10.9.2 ruby 2.0.0 rails 4.0.2 不知道是不是我的环境有问题,求解救
折腾太久这个问题,于是在 @yehualiu 的建议下选择了另一个 gem 'easy_captcha' 使用起来挺方便的。 不过还是有个问题,就是 rails s 后,报了很多很多警告,跟 rmagick 相关的(摘一段如下)
warning: already initialized constant Magick::PercentGeometry
warning: previous definition of PercentGeometry was here
warning: already initialized constant Magick::AspectGeometry
warning: previous definition of AspectGeometry was here
warning: already initialized constant Magick::LessGeometry
warning: previous definition of LessGeometry was here
……
不知道会不会存在风险。 高人路过,不吝赐教,在此谢过。