Reg*_*ius 1 mysql mongodb ruby-on-rails-4 mongoid4
我正在尝试使用MongoDB(mongoid)和MySQL一起在rails 4中创建应用程序.但是我无法设置它.
我按照以下步骤操作:
rails new myapp -d mysqlgem "mongoid"gem "bson_ext"bundle installrails g mongoid:config第4步失败.我无法弄清楚问题所在.它显示以下错误.
/home/devesh/.rvm/gems/ruby-2.2.2/gems/mongoid-1.0.6/lib/mongoid/associations.rb:5:in
require': /home/devesh/.rvm/gems/ruby-2.2.2/gems/mongoid-1.0.6/lib/mongoid/associations/has_many.rb:79: syntax error, unexpected keyword_do_cond, expecting ':' @documents = attributes ? attributes.collect do |attrs| ^ /home/devesh/.rvm/gems/ruby-2.2.2/gems/mongoid-1.0.6/lib/mongoid/associations/has_many.rb:84: syntax error, unexpected ':', expecting keyword_end end : [] ^ /home/devesh/.rvm/gems/ruby-2.2.2/gems/mongoid-1.0.6/lib/mongoid/associations/has_many.rb:99: syntax error, unexpected keyword_do_cond, expecting keyword_end attributes.values.each do |attrs| ^ /home/devesh/.rvm/gems/ruby-2.2.2/gems/mongoid-1.0.6/lib/mongoid/associations/has_many.rb:139: syntax error, unexpected keyword_end, expecting end-of-input (SyntaxError) from /home/devesh/.rvm/gems/ruby-2.2.2/gems/mongoid-1.0.6/lib/mongoid/associations.rb:5:in'来自/home/devesh/.rvm/gems/ruby-2.2 .2/gems/mongoid-1.0.6/lib/mongoid.rb:40:require' from /home/devesh/.rvm/gems/ruby-2.2.2/gems/mongoid-1.0.6/lib/mongoid.rb:40:inin'from /home/devesh/.rvm/gems/ruby-2.2.2/gems/bundler-1.10.6/lib/bundler/ runtime.rb:76:在require' from /home/devesh/.rvm/gems/ruby-2.2.2/gems/bundler-1.10.6/lib/bundler/runtime.rb:76:inblock(2级)的require'from /home/devesh/.rvm/gems/ruby-2.2.2/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:在each' from /home/devesh/.rvm/gems/ruby-2.2.2/gems/bundler-1.10.6/lib/bundler/runtime.rb:72:in要求'from /home/devesh/.rvm/gems/ruby-2.2.2/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in require'fromeach' from /home/devesh/.rvm/gems/ruby-2.2.2/gems/bundler-1.10.6/lib/bundler/runtime.rb:61:in/ home/devesh /. rvm/gems/ruby-2.2.2/gems/bundler-1.10.6/lib/bundler.rb:134:require' from /home/devesh/fashion_hub/store/config/application.rb:7:inin'from /home/devesh/.rvm/gems/ruby-2.2.2/gems/spring-1.3 0.6/LIB /弹簧/ application.rb中:82:在require' from /home/devesh/.rvm/gems/ruby-2.2.2/gems/spring-1.3.6/lib/spring/application.rb:82:in预装'来自/home/devesh/.rvm/gems/ruby-2.2.2/gems/spring-1.3.6/lib/spring/application.rb:143:inserve' from /home/devesh/.rvm/gems/ruby-2.2.2/gems/spring-1.3.6/lib/spring/application.rb:131:inblock in run'from /home/devesh/.rvm /gems/ruby-2.2.2/gems/spring-1.3.6/lib/spring/application.rb:125:inloop' from /home/devesh/.rvm/gems/ruby-2.2.2/gems/spring-1.3.6/lib/spring/application.rb:125:inrun from from /home/devesh/.rvm/gems/ruby-2.2.2/gems/spring -1.3.6/lib/spring/application/boot.rb:18:in<top (required)>' from /home/devesh/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:inrequire'from /home/devesh/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext /kernel_require.rb:54:在`require'中
我正在关注这个网址.
一些细节:
将这些行添加到您的application.rb文件中:
config.generators do |g|
g.orm :active_record
end
这将强制rails g使用活动记录.
无论何时您想为mongodb生成模型,请使用:
rails g mongoid:model yourmodelname
| 归档时间: |
|
| 查看次数: |
1861 次 |
| 最近记录: |