0

我跑:

$ rails g scaffold User first_name:string last_name:string email:string website:string nodes:array links:array --orm=mongo_mapper

并得到:

invoke  mongo_mapper
create    app/models/user.rb
(erb):1:in `template': undefined method `module_namespacing' for #<MongoMapper::Generators::ModelGenerator:0x000000035cd4a8> (NoMethodError)
...
from /home/thrive/.rvm/gems/ruby-1.9.2-p290@mlrepo/gems/mongo_mapper-0.11.1/lib/rails/generators/mongo_mapper/model/model_generator.rb:17:in `create_model_file'
...

完整的错误输出...有人知道这里发生了什么吗?

我的意思是它是一个 .rb 文件,其中看起来是 ERB 代码:

<%= module_namespacing do - %>

导致文件的错误:

4

1 回答 1

1

看起来名为“generator-parent-option”的边缘分支可以解决问题:

#/Gemfile
gem 'mongo_mapper', :git => 'git://github.com/bearded/mongomapper.git', :branch => 'generator-parent-option'

我跑了:

$ rails g scaffold User first_name:string last_name:string email:string website:string nodes:array links:array --skip-migration --orm=mongo_mapper

并得到了干净的输出:

thrive@thrive-laptop:~/rails_projects/hive$ rails g scaffold User first_name:string last_name:string email:string website:string nodes:array links:array --skip-migration --orm=mongo_mapper
      invoke  mongo_mapper
    conflict    app/models/user.rb
  Overwrite /home/thrive/rails_projects/hive/app/models/user.rb? (enter "h" for help) [Ynaqdh] h
  Y - yes, overwrite
n - no, do not overwrite
a - all, overwrite this and all others
q - quit, abort
d - diff, show the differences between the old and the new
h - help, show this help
  Overwrite /home/thrive/rails_projects/hive/app/models/user.rb? (enter "h" for help) [Ynaqdh] Y
       force    app/models/user.rb
      invoke    test_unit
      create      test/unit/user_test.rb
      create      test/fixtures/users.yml
       route  resources :users
      invoke  scaffold_controller
   identical    app/controllers/users_controller.rb
      invoke    haml
       exist      app/views/users
   identical      app/views/users/index.html.haml
   identical      app/views/users/edit.html.haml
   identical      app/views/users/show.html.haml
   identical      app/views/users/new.html.haml
   identical      app/views/users/_form.html.haml
      invoke    test_unit
   identical      test/functional/users_controller_test.rb
      invoke    helper
   identical      app/helpers/users_helper.rb
      invoke      test_unit
   identical        test/unit/helpers/users_helper_test.rb
      invoke  stylesheets
   identical    public/stylesheets/scaffold.css
于 2012-05-15T14:47:41.520 回答