Rails 3.1 脚手架生成器因项目而损坏,刚刚停止工作:没有要加载的文件 --rails_generator (LoadError)

发布于 2024-12-31 21:11:54 字数 583 浏览 0 评论 0原文

已解决,请参阅下面的评论,发现“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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

薄荷梦 2025-01-07 21:11:54

解决了。修复方法如下:

  1. 注释掉 Gemfile 中的 enumerated_attribute gem
  2. 进行脚手架
  3. 替换 Gemfile 中的 enumerated_attribute gem。

Solved. Here is the fix:

  1. Comment out enumerated_attribute gem in the Gemfile
  2. Do scaffolding
  3. Replace enumerated_attribute gem in the Gemfile.

仅删除 enumerated_attribute 对我来说不起作用。然后,我收到错误,抱怨未定义的方法“enum_attr”(如您所料),这意味着我还需要使用 enum_attr 注释掉模型的每个属性。我使用了以下 gem 版本:

gem 'enumerated_attribute', :git => 'git://github.com/jeffp/enumerated_attribute.git'

这解决了我的问题。

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:

gem 'enumerated_attribute', :git => 'git://github.com/jeffp/enumerated_attribute.git'

This fixed the issue for me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文