2013-08-20 86 views
3

我想爲應用程序生成一些設計視圖,但每當我嘗試使用命令rails g devise:views時,我都會遇到一個複雜的錯誤,遠遠超出我的理解。Rails 4生成設計視圖

/Users/michaeldunnegan/.rvm/gems/ruby-2.0.0-p247/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:0x007ff613f5bb10 @paths=["/Users/michaeldunnegan/projects/SoundShare/config/routes.rb"], @route_sets=[#<ActionDispatch::Routing::RouteSet:0x007ff6168369e0>]> (RuntimeError) 
    from /Users/michaeldunnegan/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:6:in `execute_if_updated' 
    from /Users/michaeldunnegan/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>' 
    from /Users/michaeldunnegan/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `instance_exec' 
    from /Users/michaeldunnegan/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `run' 
    from /Users/michaeldunnegan/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/initializable.rb:55:in `block in run_initializers' 
    from /Users/michaeldunnegan/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each' 
    from /Users/michaeldunnegan/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component' 
    from /Users/michaeldunnegan/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from' 
    from /Users/michaeldunnegan/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component' 
    from /Users/michaeldunnegan/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:180:in `each' 
    from /Users/michaeldunnegan/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component' 
    from /Users/michaeldunnegan/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each' 
    from /Users/michaeldunnegan/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/initializable.rb:54:in `run_initializers' 
    from /Users/michaeldunnegan/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/application.rb:215:in `initialize!' 
    from /Users/michaeldunnegan/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in `method_missing' 
    from /Users/michaeldunnegan/projects/SoundShare/config/environment.rb:4:in `<top (required)>' 
    from /Users/michaeldunnegan/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require' 
    from /Users/michaeldunnegan/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require' 
    from /Users/michaeldunnegan/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency' 
    from /Users/michaeldunnegan/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require' 
    from /Users/michaeldunnegan/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/application.rb:189:in `require_environment!' 
    from /Users/michaeldunnegan/.rvm/gems/ruby-2.0.0-p247/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>' 

其中一個線,/Users/michaeldunnegan/projects/SoundShare/config/environment.rb:4:in「`

很有趣。所有我在那個文件是:

# Load the Rails application. 
require File.expand_path('../application', __FILE__) 

SoundShare::Application.initialize! # this is the line 
+0

這是否僅在試圖生成設計視圖或執行任何生成器或耙式任務時發生?如果是後者,看起來您的路線文件中可能存在問題。 – sockmonk

+0

你的設計寶石版本是什麼? – rmagnum2002

+0

在gemfile中:gem'devise','3.0.0.rc'。事實上,每當我嘗試使用generate或rake時都會發生這種情況。 – Mike

回答

4
  1. 確保您有devise寶石與軌道4 gem 'devise', '~> 3.0.0.rc' #or higher

  2. 運行bundle update

  3. 刪除devise.rbinitializers,然後運行devise:install兼容再次在初始化程序中安裝新的配置。

  4. 確保您運行devise模型生成,例如rails g devise User

  5. 現在你應該可以運行:rails g devise:views

編輯

中的TeamViewer工作邁克的後電腦,我們從軌道4上的一個工作項目中拿到了一份devise.rb,並將其放入config/initializers/

接下來我們運行了rails generate devise:install命令,它說了一些關於棄用的內容,並詢問我們是否要替換devise.rb文件的內容。我們接受了它,之後所有的設計命令都運行良好。

+0

第一:我的初始化文件夾中沒有devise.rb文件。第二:當我運行'rails g設計:安裝'時,我得到了原始帖子中的錯誤 – Mike

+0

看看你是否可以加入這個聊天http://chat.stackoverflow.com/rooms/35947/http-stackoverflow-com-questions -18344517-rails-4-generate-devise-views – rmagnum2002

+0

ight。我加入了聊天 – Mike