0

在我新创建的 Rails 4 应用程序中,我突然点击rails g devise install而不是rails g devise:install. install在这个错误之后,根据我从这个输出中的理解生成了设计组件:

  invoke  active_record
  create    db/migrate/20130921224627_devise_create_installs.rb
  create    app/models/install.rb
  insert    app/models/install.rb
   route  devise_for :installs

当我尝试像 一样回滚时rails d migration install,由于未设置而失败config.secret_keydevise.rb但也没有文件命名它。我什至无法运行rails g devise:install创建devise.rb文件和添加密钥配置。在此过程之后,发生了另一个错误:

    /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:10:in `rescue in execute_if_updated': Rails::Application::RoutesReloader#execute_if_updated delegated to updater.execute_if_updated, but updater is nil: #<Rails::Application::RoutesReloader:0x007f6c66a67848 @paths=["/home/ekrem/workspace/contactman4/config/routes.rb"], @route_sets=[#<ActionDispatch::Routing::RouteSet:0x007f6c66ac1c80>]> (RuntimeError)
        from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:6:in `execute_if_updated'
        from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'
        from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `instance_exec'
        from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `run'
        from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:55:in `block in run_initializers'
        from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'
        from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
        from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'
        from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'
        from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/tsort.rb:180:in `each'
        from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'
        from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'
        from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:54:in `run_initializers'
        from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:215:in `initialize!'
        from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
        from /home/ekrem/workspace/contactman4/config/environment.rb:5:in `<top (required)>'
        from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
        from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
        from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
        from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
        from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:189:in `require_environment!'
        from /home/ekrem/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:45:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'

我该如何纠正这个错误?

4

1 回答 1

1

有几种方法可以解决这个问题,但我更喜欢删除生成器创建的所有内容。

  • 迁移
  • 该模型
  • 路线

我没有看到您正在运行该rake db:migrate命令,因此可能不会提交迁移。如果是,则 run rake db:rollbackwich 将回滚最后一次迁移。

最后一个想法给你。您应该真正学习如何使用 Git(或您喜欢的任何其他 VCS)。因为这正是 VCS 旨在解决的问题之一。

于 2013-09-22T05:38:25.143 回答