Rails 3.1 脚手架生成器因项目而损坏,刚刚停止工作:没有要加载的文件 --rails_generator (LoadError)
已解决,请参阅下面的评论,发现“enumerated_attribute”宝石破坏了 Rails 脚手架
我的 Rails 3.1 脚手架刚刚在我的项目中损坏。 (脚手架在我的其他 3.0 和 3.1 项目中仍然运行良好 - 只有一个项目的脚手架生成器损坏了!)
在我的 Rail 3.1 项目中,过去几天我搭建了多个模型,然后今天突然出现了 rails gscaffold Mymodel
失败并显示错误消息:
/Users/johndoe/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/lib/active_support/dependency.rb:240:in `require':没有要加载的文件——rails_generator (LoadError)
我没有中途切换rails版本或其他任何东西,该项目一直是rails 3.1.3,并且一直工作正常,直到我今天再次尝试它一个新的模型。
有谁知道如何修复它和/或什么可能导致它突然损坏?
(rails g 迁移工作正常......只是脚手架坏了!)
SOLVED, see comment below, discovered 'enumerated_attribute' gem breaks rails scaffold
My rails 3.1 scaffolding just broke for my project. (scaffolding still works fine in my other 3.0 and 3.1 projects-- only one project has a broken scaffold generator!)
In my rail 3.1 project, I have scaffolded multiple models the past few days, then today out of the blue rails g scaffold Mymodel
is failing with the error message:
/Users/johndoe/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in
`require': no such file to load -- rails_generator (LoadError)
I didn't switch rails versions mid-way or anything, the project has always been rails 3.1.3, and it's been working fine until I tried it again today for a new model.
Does anyone have any idea how to fix it and/or what might have caused it to suddenly break?
(rails g migration works fine... it's just scaffolding that is broken!)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
解决了。修复方法如下:
enumerated_attribute
gemenumerated_attribute
gem。Solved. Here is the fix:
enumerated_attribute
gem in the Gemfileenumerated_attribute
gem in the Gemfile.仅删除 enumerated_attribute 对我来说不起作用。然后,我收到错误,抱怨未定义的方法“enum_attr”(如您所料),这意味着我还需要使用 enum_attr 注释掉模型的每个属性。我使用了以下 gem 版本:
这解决了我的问题。
Just removing enumerated_attribute did not work for me. I then got errors complaining about undefined method 'enum_attr' (as you would expect), meaning I need to also comment out every attr of my models using enum_attr. I used the following gem version:
This fixed the issue for me.