简体   繁体   English

导轨产生迁移不起作用

[英]rails generate migration doesn't work

I am new to Rails, and I wanted to add an email confirmation. 我是Rails的新手,我想添加一封电子邮件确认。 I tried this: 我尝试了这个:

 rails generate migration   AddEmailConfirmedAndConfirmTokenToUser email_confirmed:boolean confirm_token:string

but didn't work it shows this error: 但不起作用,它显示此错误:

Running via Spring preloader in process 19269 error mongoid [not found] 在过程19269中通过Spring预加载器运行,错误Mongoid [未找到]

Since mongodb doesn't start in my project I am working on without using sudo mongod I tried adding sudo before rails generate migration like: 由于mongodb不在我的项目中启动,因此我在不使用sudo mongod的情况下进行工作,因此我尝试在rails生成迁移之前添加sudo,例如:

sudo rails generate migration AddEmailConfirmedAndConfirmTokenToUser email_confirmed:boolean confirm_token:string

but instead I get this: 但是我得到了这个:

/Users/.../.rvm/rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems.rb:271:in `find_spec_for_exe': can't find gem railties (>= 0.a) (Gem::GemNotFoundException)
        from /Users/.../.rvm/rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems.rb:299:in `activate_bin_path'
        from /Users/.../.rvm/gems/ruby-2.3.1/bin/rails:23:in `<main>'
        from /Users/.../.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `eval'
        from /Users/.../.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `<main>'

I did some research and was suggested to me to update Bundler but that didn't work either. 我做了一些研究,并建议我更新Bundler,但那也不起作用。 I have no idea how to solve this, any suggestion would be appreciated! 我不知道如何解决这个问题,任何建议将不胜感激!

MongoDB不需要迁移,您可以仅在模型上添加一个字段(如果已创建)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM