ruby datamapper无法加载[英] ruby datamapper will not load

本文是小编为大家收集整理的关于ruby datamapper无法加载的处理方法,想解了ruby datamapper无法加载的问题怎么解决?ruby datamapper无法加载问题的解决办法?那么可以参考本文帮助大家快速定位并解决问题。

问题描述

我试图通过遵循本教程来了解Sinatra Ruby框架:

http://net.tut.tutsplus .com/tutorials/ruby/singing-with-sinatra-the-recall-app-2/

但是,在运行GEM安装并在test.rb中编写简单的Sinatra服务器之后.

:

require 'sinatra'
require 'datamapper'

get '/' do 
  "Hello, World!"
end

但是当我运行命令ruby test.rb时,我会收到以下错误:

/usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': no such file to load -- datamapper (LoadError)
    from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from datamapper_test.rb:2:in `<main>'
glenn@ubuntu:~/Dropbox/Repositories/sandbox/sinatra$ ruby datamapper_test.rb 
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': no such file to load -- datamapper (LoadError)
    from /usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from test.rb:3:in `<main>'

似乎找不到DatamApper GEM.我该如何解决?

编辑:使用Ruby 1.9.2

编辑(再次) :(校园)输出gem list:

data_mapper (1.2.0)
data_objects (0.10.8)
datamapper (1.2.0)
devise (1.4.5)
directory_watcher (1.4.0)
dm-aggregates (1.2.0)
dm-constraints (1.2.0)
dm-core (1.2.0)
dm-do-adapter (1.2.0)
dm-migrations (1.2.0)
dm-serializer (1.2.1)
dm-sqlite-adapter (1.2.0)
d    m-timestamps (1.2.0)
dm-transactions (1.2.0)
dm-types (1.2.1)
dm-validations (1.2.0)
do_sqlite3 (0.10.8)
sinatra (1.3.2, 1.2.6)
sqlite3 (1.3.5, 1.3.4)
sqlite3-ruby (1.3.3)

推荐答案

您需要require 'data_mapper',而不是datamapper.

请注意,有一个datamapper宝石和data_mapper宝石,但它们是同一件事,只是不同的名称.您需要在两个中使用data_mapper作为库名.

据我所知,datamapper是data_mapper的直副本:

$ diff -r data_mapper-1.2.0/ datamapper-1.2.0/
diff -r data_mapper-1.2.0/Rakefile datamapper-1.2.0/Rakefile
21c21
< GEM_NAME         = 'data_mapper'
---
> GEM_NAME         = 'datamapper'

其他推荐答案

gem install datamapper在您的终端中可能会有所帮助:) 但是您还需要一个数据库和一个适配器,并且您需要以某种方式使用宝石.祝您好运,并与DM + Sinatra一起玩!

本文地址:https://www.itbaoku.cn/post/786541.html