我正在尝试用rails测试mongoDB,我对两者都很陌生。
首先,安装了 mongoDB 并作为 Windows 服务运行。
现在,这是我创建一个简单应用程序的步骤:
我用这个创建了应用程序:
rails new MongoOnRailsBlog -O -J -T
然后我修改了 gemfile,它现在看起来像这样:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'
gem 'mongoid'
gem 'bson_ext'
gem 'will_paginate'
gem 'devise'
gem 'haml'
gem 'haml-rails', :group => :development
gem 'hpricot', :group => :development
gem 'formtastic'
gem 'jquery-rails'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
我修改了 application.rb 以添加一些生成器:
require File.expand_path('../boot', __FILE__)
require "action_controller/railtie"
require "action_mailer/railtie"
require "sprockets/railtie"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env)
module MongoOnRailsBlog
class Application < Rails::Application
# Configure generators
config.generators do |g|
g.orm :mongoid
g.template_engine :haml
end
end
end
然后,当我尝试生成 mongoID 配置时,使用以下命令:
rails generate mongoid:config
我有“无法加载文件错误”
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require': cannot load such file -- mongoid/version (LoadError)
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/devise-1.5.4/lib/devise/rails.rb:34:in `block in <class:Engine>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `instance_exec'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `run'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:55:in `block in run_initializers'
from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'
from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) ineach_strongly_connected_component'
from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'
from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'
from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:180:in `each'
from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'
from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:54:in `run_initializers'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:215:in `initialize!'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
from E:/Dev/Projects/MongoOnRailsBlog/config/environment.rb:5:in `<top (required)>'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:189:in `require_environment!'
from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:45:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
我猜它与 MongoID 的好版本有关,但我不知道在哪里验证,如何确保它加载好的版本......
关于在哪里看的任何建议?
感谢。