我跑:
$ 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'
...
full error output ......有谁知道这里发生了什么?
我的意思是它的.rb文件,其中包含看起来像ERB代码的内容:
<%= module_namespacing do - %>
导致文件错误:
答案 0 :(得分: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