我正在尝试在仅Rails API的应用中创建新模型,但出现“无法加载此类文件”错误消息:
/Users/max/.rvm/gems/ruby-2.6.3/gems/spring-2.0.2/lib/spring/application.rb:171:in `fork': cannot load such file -- rails/generators/model/model/model_generator (LoadError)
/Users/max/.rvm/gems/ruby-2.6.3/gems/spring-2.0.2/lib/spring/application.rb:171:in `fork': undefined method `reject!' for nil:NilClass (NoMethodError)
/Users/max/.rvm/gems/ruby-2.6.3/gems/spring-2.0.2/lib/spring/application.rb:171:in `fork': undefined method `join' for nil:NilClass (NoMethodError)
/Users/max/.rvm/gems/ruby-2.6.3/gems/spring-2.0.2/lib/spring/application.rb:171:in `fork': undefined method `reject!' for nil:NilClass (NoMethodError)
/Users/max/.rvm/gems/ruby-2.6.3/gems/spring-2.0.2/lib/spring/application.rb:171:in `fork': undefined method `reject!' for nil:NilClass (NoMethodError)
/Users/max/.rvm/gems/ruby-2.6.3/gems/spring-2.0.2/lib/spring/application.rb:171:in `fork': undefined method `reject!' for nil:NilClass (NoMethodError)
我已经更改了ruby版本,但是没有用。
rails generate model Product title:string release_date:date release_time:time description:text price:decimal brand:string
答案 0 :(得分:1)
我认为这是一个已知问题,但是您应该能够使用以下方法运行一次性rails命令,而无需停止spring:
DISABLE_SPRING=1 rails generate model Product title:string release_date:date release_time:time description:text price:decimal brand:string
或者您可以先运行spring stop
也请在此处查看答案Rails Spring breaking generators