未初始化的常量Rails :: Generator :: GeneratedAttribute :: ActiveRecord

时间:2013-08-20 21:16:06

标签: ruby-on-rails scaffolding ruby-on-rails-2

当我尝试运行命令时使用rails 2.3.5:script/generate scaffold user user_name:string email:string,我收到错误:

uninitialized constant Rails::Generator::GeneratedAttribute::ActiveRecord

我搜索过此错误,但我发现唯一的解决办法就是在environment.rb

取消注释这一行
config.frameworks -= [ :active_record, :active_resource, :action_mailer ]

在我的环境中已经取消注释。我该怎么办?

1 个答案:

答案 0 :(得分:0)

一个新手的故障:),我来自rails 3,我已经安装了bundle以便能够在我的rails 2项目中安装宝石但是我不知道我应该在使用bundler的情况下再次评论上面的行因为在添加bundler的说明中没有提及。

评论# config.frameworks -= [ :active_record, :active_resource, :action_mailer ]

然后我得到以下

➜  ~  script/generate scaffold user user_name:string email:string
      exists  app/models/
      exists  app/controllers/
      exists  app/helpers/
      exists  app/views/users
      exists  app/views/layouts/
      exists  test/functional/
      exists  test/unit/
      exists  test/unit/helpers/
      exists  public/stylesheets/
overwrite app/views/users/index.html.erb? (enter "h" for help) [Ynaqdh] y
       force  app/views/users/index.html.erb
      create  app/views/users/show.html.erb
      create  app/views/users/new.html.erb
      create  app/views/users/edit.html.erb
      create  app/views/layouts/users.html.erb
      create  public/stylesheets/scaffold.css
      create  app/controllers/users_controller.rb
      create  test/functional/users_controller_test.rb
      create  app/helpers/users_helper.rb
      create  test/unit/helpers/users_helper_test.rb
       route  map.resources :users
  dependency  model
      exists    app/models/
      exists    test/unit/
      exists    test/fixtures/
      create    app/models/user.rb
      create    test/unit/user_test.rb
      create    test/fixtures/users.yml
      create    db/migrate
      create    db/migrate/20130820214343_create_users.rb

rake db:migrate完成了,这意味着一切都很好吗?