2015-07-11 106 views
0

我最近開始在新項目中生成控制器,型號和啓動軌服務器時遇到問題。我可以在舊項目中完成所有這些工作。無法生成控制器,型號或啓動軌服務器

可以做些什麼來解決這個錯誤?

操作系統:Ubuntu的15.04,紅寶石:2.1時,Rails:4.2.0

錯誤輸出

[email protected]:~/testRails/blog$ rails g controller pages 

Warning: Running `gem pristine --all` to regenerate your installed gemspecs (and deleting then reinstalling your bundle if you use bundle --path) will improve the startup performance of Spring. 
/var/lib/gems/2.1.0/gems/railties-4.2.0/lib/rails/railtie/configuration.rb:95:in `method_missing': undefined method `active_record' for #<Rails::Application::Configuration:0x00000002ec6c40> (NoMethodError) 
    from /home/aditya/testRails/blog/config/application.rb:24:in `<class:Application>' 
    from /home/aditya/testRails/blog/config/application.rb:10:in `<module:Blog>' 
    from /home/aditya/testRails/blog/config/application.rb:9:in `<top (required)>' 
    from /var/lib/gems/2.1.0/gems/spring-1.3.6/lib/spring/application.rb:82:in `require' 
    from /var/lib/gems/2.1.0/gems/spring-1.3.6/lib/spring/application.rb:82:in `preload' 
    from /var/lib/gems/2.1.0/gems/spring-1.3.6/lib/spring/application.rb:143:in `serve' 
    from /var/lib/gems/2.1.0/gems/spring-1.3.6/lib/spring/application.rb:131:in `block in run' 
    from /var/lib/gems/2.1.0/gems/spring-1.3.6/lib/spring/application.rb:125:in `loop' 
    from /var/lib/gems/2.1.0/gems/spring-1.3.6/lib/spring/application.rb:125:in `run' 
    from /var/lib/gems/2.1.0/gems/spring-1.3.6/lib/spring/application/boot.rb:18:in `<top (required)>' 
    from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require' 
    from /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require' 
    from -e:1:in `<main>' 

編輯:我取下導軌完全和再次進行安裝。但沒有效果,仍然有這個錯誤。

回答

0

您是否嘗試在應用程序中運行軟件包安裝?

+0

是,捆綁安裝運行良好。但生成命令和啓動軌服務器不起作用。 –

0

根據錯誤好像你在/home/aditya/testRails/blog/config/application.rb:24

創建一個新的Rails應用,而無需ActiveRecord的

'method_missing': undefined method 'active_record' for #Rails::Application::Configuration

的堆棧跟蹤暗示如果刪除的ActiveRecord是故意跟着刪除任何有關積極記錄,如果不能繼續閱讀,因爲你可能會發現丟失了什麼;)

  • 刪除任何activerecord configapplication.rb中環境/ *

  • 檢查的config/application.rb中如果 require 'rails/all存在,將其刪除,並添加railties,你需要這樣的:

    require "action_controller/railtie" 
    require "action_mailer/railtie" 
    require "active_job/railtie" 
    require "sprockets/railtie" 
    require "rails/test_unit/railtie" 
    # require "railtie/active_record" 
    
  • 從Gemfile中刪除任何adapter(mysql2,pg,sqlite3)

  • 刪除配置/ database.yml的

希望它能幫助:)

+0

做完你所說的在生成模型時出現這個錯誤:錯誤:**/var/lib/gems/2.1.0/gems/arel-6.0.1/lib/arel.rb:2:in'require':can not加載這樣的文件 - arel/factory_methods(LoadError)**。我不知道如何,但現在當我創建一個新項目時,它的工作正常。我仍然在舊項目中遇到問題,這些項目向我展示了這些錯誤。他們面前的新項目和項目工作正常。 –

+0

可能Bundle安裝對於顯示這些錯誤的項目無法正常工作。 –