2013-07-10 35 views
1

我想補充以下遷移:錯誤添加遷移:`default_controller_and_action:缺少:動作(引發ArgumentError)

rails g migration AddConfirmableToUsers confirmation_token:string confirmed_at:datetime confirmation_sent_at:datetime unconfirmed_email:string 

但是,它提出了以下錯誤,我無法排除故障:

/Users/tn/.rvm/gems/[email protected]/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:179:in `default_controller_and_action': missing :action (ArgumentError) 
    from /Users/tn/.rvm/gems/[email protected]/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:72:in `normalize_options!' 
    from /Users/tn/.rvm/gems/[email protected]/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:60:in `initialize' 
    from /Users/tn/.rvm/gems/[email protected]/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:1308:in `new' 
    from /Users/tn/.rvm/gems/[email protected]/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:1308:in `add_route' 
    from /Users/tn/.rvm/gems/[email protected]/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:1287:in `decomposed_match' 
    from /Users/tn/.rvm/gems/[email protected]/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:1269:in `block in match' 
    from /Users/tn/.rvm/gems/[email protected]/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:1269:in `each' 
    from /Users/tn/.rvm/gems/[email protected]/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:1269:in `match' 
    from /Users/tn/.rvm/gems/[email protected]/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:254:in `root' 
    from /Users/tn/.rvm/gems/[email protected]/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:1321:in `root' 
    from /Users/tn/rails_projects/rails-prelaunch-signup/config/routes.rb:5:in `block in <top (required)>' 
    from /Users/tn/.rvm/gems/[email protected]/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:289:in `instance_exec' 
    from /Users/tn/.rvm/gems/[email protected]/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:289:in `eval_block' 
    from /Users/tn/.rvm/gems/[email protected]/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:267:in `draw' 
    from /Users/tn/rails_projects/rails-prelaunch-signup/config/routes.rb:1:in `<top (required)>' 
    from /Users/tn/.rvm/gems/[email protected]/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in `load' 
    from /Users/tn/.rvm/gems/[email protected]/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in `block in load' 
    from /Users/tn/.rvm/gems/[email protected]/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency' 
    from /Users/tn/.rvm/gems/ruby-2[email protected]/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in `load' 
    from /Users/tn/.rvm/gems/[email protected]/gems/railties-3.2.13/lib/rails/application/routes_reloader.rb:40:in `block in load_paths' 
    from /Users/tn/.rvm/gems/[email protected]/gems/railties-3.2.13/lib/rails/application/routes_reloader.rb:40:in `each' 
    from /Users/tn/.rvm/gems/[email protected]/gems/railties-3.2.13/lib/rails/application/routes_reloader.rb:40:in `load_paths' 
    from /Users/tn/.rvm/gems/[email protected]/gems/railties-3.2.13/lib/rails/application/routes_reloader.rb:16:in `reload!' 
    from /Users/tn/.rvm/gems/[email protected]/gems/railties-3.2.13/lib/rails/application/routes_reloader.rb:26:in `block in updater' 
    from /Users/tn/.rvm/gems/[email protected]/gems/activesupport-3.2.13/lib/active_support/file_update_checker.rb:78:in `call' 
    from /Users/tn/.rvm/gems/[email protected]/gems/activesupport-3.2.13/lib/active_support/file_update_checker.rb:78:in `execute' 
    from /Users/tn/.rvm/gems/[email protected]/gems/railties-3.2.13/lib/rails/application/routes_reloader.rb:27:in `updater' 
    from /Users/tn/.rvm/gems/[email protected]/gems/railties-3.2.13/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated' 
    from /Users/tn/.rvm/gems/[email protected]/gems/railties-3.2.13/lib/rails/application/finisher.rb:66:in `block in <module:Finisher>' 
    from /Users/tn/.rvm/gems/[email protected]/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec' 
    from /Users/tn/.rvm/gems/[email protected]/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run' 
    from /Users/tn/.rvm/gems/[email protected]/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers' 
    from /Users/tn/.rvm/gems/[email protected]/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each' 
    from /Users/tn/.rvm/gems/[email protected]/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers' 
    from /Users/tn/.rvm/gems/[email protected]/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!' 
    from /Users/tn/.rvm/gems/[email protected]/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing' 
    from /Users/tn/rails_projects/rails-prelaunch-signup/config/environment.rb:5:in `<top (required)>' 
    from /Users/tn/.rvm/gems/[email protected]/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require' 
    from /Users/tn/.rvm/gems/[email protected]/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require' 
    from /Users/tn/.rvm/gems/[email protected]/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency' 
    from /Users/tn/.rvm/gems/[email protected]/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require' 
    from /Users/tn/.rvm/gems/[email protected]/gems/railties-3.2.13/lib/rails/application.rb:103:in `require_environment!' 
    from /Users/tn/.rvm/gems/[email protected]/gems/railties-3.2.13/lib/rails/commands.rb:25:in `<top (required)>' 
    from script/rails:6:in `require' 
    from script/rails:6:in `<main>' 

我認爲這可能是我的routes.rb文件的問題,但無法找到它的問題。

RailsPrelaunchSignup::Application.routes.draw do 

    root to: "root_path" 

end 

User.rb

class User < ActiveRecord::Base 
    rolify 
    # Include default devise modules. Others available are: 
    # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable 
    devise :database_authenticatable, :registerable, :confirmable, 
     :recoverable, :rememberable, :trackable, :validatable 

    # Setup accessible (or protected) attributes for your model 
    attr_accessible :name, :email, :password, :password_confirmation, :remember_me 

end 

任何幫助,將不勝感激!

回答

2

這的確是你的路由文件:

root to: "root_path" 

這應該是這樣的:

root to: "controller#action" 

root_path是由Rails的,當你在一個root定義自動生成的助手名的路線文件。

+0

謝謝@Ryan Bigg!我更新了路徑文件以反映教程的Github頁面上的實現:https://github.com/RailsApps/rails-prelaunch-signup/blob/master/config/routes.rb –

相關問題