rails-api不允许任何一代

时间:2014-06-14 22:37:37

标签: mongodb mongomapper rails-api

我正在努力尝试使用mongo_mapper gem获取rails-api的配置。

我正在使用rails v 4.1.1

gemfile如下所示

source 'https://rubygems.org'

gem 'mongo'
gem 'mongo_mapper', :git => "git://github.com/mongomapper/mongomapper.git", :tag => "v0.13.0.beta2"
gem 'bson_ext'
gem 'railties'

我运行了rails-api new test-app --skip-active-record,它生成了一个简单的文件结构。

.
├── Gemfile
├── Gemfile.lock
├── README.rdoc
├── Rakefile
└── config.ru

之后,根据mongo_mapper的README上的说明,我在gemfile中指定了正确的版本,以便它与Rails 4兼容。

gem 'mongo_mapper', :git => "git://github.com/mongomapper/mongomapper.git", :tag => "v0.13.0.beta2"

根据 - http://mongomapper.com/documentation/getting-started/rails.html - How can I get mongo mapper to generate the config/mongo.yml file in Rails 4

然后我应该能够运行bundle exec rails generate mongo_mapper:config。就在这里,我开始遇到问题。

我第一次意识到我需要railsties gem,因为它甚至不让我运行rails generate。

$ bundle exec rails generate mongo_mapper:config
/Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.6.1/lib/bundler/rubygems_integration.rb:248:in `block in replace_gem': railties is not part of the bundle. Add it to Gemfile. (Gem::LoadError)
    from /Users/colinhhart/.rbenv/versions/2.1.0/bin/rails:22:in `<main>'

添加该gem之后,它允许我运行bundle exec rails generate mongo_mapper:config但实际上无法访问该mongo生成器。该命令的输出是标准的rails帮助信息,包括用法,选项等。

Usage:
  rails new APP_PATH [options]

Options:
  -r, [--ruby=PATH]                                      # Path to the Ruby binary of your choice
                                                         # Default: /Users/colinhhart/.rbenv/versions/2.1.0/bin/ruby
  -m, [--template=TEMPLATE]                              # Path to some application template (can be a filesystem path or URL)

到目前为止我尝试了什么

  • 我已经尝试按照本指南中的描述构建了生成器应该构建的内容

http://technicaldebt.com/getting-started-with-ruby/mongomapper-ith-rails-quickstart/

但后来才意识到,即使我构建它,显然仍然有一些我所缺少的“粘合剂”,它将所有东西联系在一起。为了以防万一我构建了它,当然它仍然没有用。

  • 我已确保捆绑并正确地重新加载终端。

就像我说的那样,我非常确定在没有活动记录的情况下构建rails-api时会跳过一些必要的东西。

对此有何想法?非常感谢帮助。

值得一提的是当我运行rails-api new my_app --skip-active-record时的完整输出。

$ rails-api new pitfworld_wide_atrocities_db --skip-active-record
      create  
      create  README.rdoc
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
(erb):19:in `template': undefined method `name' for []:Array (NoMethodError)
    from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/2.1.0/erb.rb:850:in `eval'
    from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/2.1.0/erb.rb:850:in `result'
    from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/actions/file_manipulation.rb:116:in `block in template'
    from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:53:in `call'
    from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:53:in `render'
    from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:62:in `block (2 levels) in invoke!'
    from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:62:in `open'
    from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:62:in `block in invoke!'
    from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/actions/empty_directory.rb:116:in `call'
    from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/actions/empty_directory.rb:116:in `invoke_with_conflict_check'
    from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:60:in `invoke!'
    from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/actions.rb:94:in `action'
    from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:25:in `create_file'
    from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/actions/file_manipulation.rb:115:in `template'
    from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/generators/rails/app/app_generator.rb:17:in `template'
    from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/generators/rails/app/app_generator.rb:45:in `gemfile'
    from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/generators/app_base.rb:133:in `build'
    from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/generators/rails/app/app_generator.rb:176:in `create_root_files'
    from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `block in invoke_all'
    from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `each'
    from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `map'
    from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `invoke_all'
    from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/group.rb:232:in `dispatch'
    from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/commands/application.rb:17:in `<top (required)>'
    from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:73:in `require'
    from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:73:in `require'
    from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.1.1/lib/rails/cli.rb:14:in `<top (required)>'
    from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:73:in `require'
    from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:73:in `require'
    from /Users/colinhhart/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/rails-api-0.2.1/bin/rails-api:4:in `<top (required)>'
    from /Users/colinhhart/.rbenv/versions/2.1.0/bin/rails-api:23:in `load'
    from /Users/colinhhart/.rbenv/versions/2.1.0/bin/rails-api:23:in `<main>'

解决方案

当我写这篇文章的时候,我遇到了rails-api问题,事实证明这就是问题,因为我永远想着这是一个mongo问题。

该问题已修复并已关闭,但尚未发布,可能会在rails-api v0.2.2中发布。

最终,我决定进入rails-api源代码并在本地应用更改。

0 个答案:

没有答案