代码之家  ›  专栏  ›  技术社区  ›  azamsharp

使用Ruby语言的MongoMapper问题

  •  0
  • azamsharp  · 技术社区  · 16 年前

    我安装了MongoMapper 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脚本/服务器启动服务器时,我得到以下异常:

    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
    
    1 回复  |  直到 16 年前
        1
  •  1
  •   theTRON    16 年前

    我想你可能在宝石名称中缺少下划线?

    尝试:

    # config/environment.rb
    config.gem "mongo_mapper"