0

我安装了 mongo mapper gem 并拥有 0.8.2 版本。我打开 environment.rb 文件并对其进行编辑以使用 MongoMapper,如下所示:

# Be sure to restart your server when you modify this file

# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.8' unless defined? RAILS_GEM_VERSION

# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')

Rails::Initializer.run do |config|

  config.gem 'mongomapper', :version => '>= 0.2.1'
  config.frameworks -= [:active_record]


  config.time_zone = 'UTC'

end

MongoMapper.database = "blog-#{Rails.env}"

当我使用 ruby​​ script/server 启动服务器时,出现以下异常:

Mohammad-Azams-MacBook-Pro:blog azamsharp$ ruby script/server
=> Booting Mongrel
=> Rails 2.3.8 application starting on http://0.0.0.0:3000
Missing these required gems:
  mongomapper  >= 0.2.1

You're running:
  ruby 1.8.7.174 at /usr/local/bin/ruby
  rubygems 1.3.7 at /Users/azamsharp/.gem/ruby/1.8, /usr/local/lib/ruby/gems/1.8
4

1 回答 1

1

我认为您可能缺少 gem 名称中的下划线?

尝试:

# config/environment.rb
config.gem "mongo_mapper"
于 2010-08-24T00:18:22.330 回答