我正在尝试添加以下迁移:
rails g migration AddConfirmableToUsers confirmation_token:string confirmed_at:datetime confirmation_sent_at:datetime unconfirmed_email:string
然而,它引发了以下错误,我无法排除故障:
/Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/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/ruby-2.0.0-rc1@global/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:72:in `normalize_options!'
from /Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:60:in `initialize'
from /Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:1308:in `new'
from /Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:1308:in `add_route'
from /Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:1287:in `decomposed_match'
from /Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:1269:in `block in match'
from /Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:1269:in `each'
from /Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:1269:in `match'
from /Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:254:in `root'
from /Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/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/ruby-2.0.0-rc1@global/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:289:in `instance_exec'
from /Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:289:in `eval_block'
from /Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/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/ruby-2.0.0-rc1@global/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in `load'
from /Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in `block in load'
from /Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
from /Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in `load'
from /Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/gems/railties-3.2.13/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
from /Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/gems/railties-3.2.13/lib/rails/application/routes_reloader.rb:40:in `each'
from /Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/gems/railties-3.2.13/lib/rails/application/routes_reloader.rb:40:in `load_paths'
from /Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/gems/railties-3.2.13/lib/rails/application/routes_reloader.rb:16:in `reload!'
from /Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/gems/railties-3.2.13/lib/rails/application/routes_reloader.rb:26:in `block in updater'
from /Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/gems/activesupport-3.2.13/lib/active_support/file_update_checker.rb:78:in `call'
from /Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/gems/activesupport-3.2.13/lib/active_support/file_update_checker.rb:78:in `execute'
from /Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/gems/railties-3.2.13/lib/rails/application/routes_reloader.rb:27:in `updater'
from /Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/gems/railties-3.2.13/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
from /Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/gems/railties-3.2.13/lib/rails/application/finisher.rb:66:in `block in <module:Finisher>'
from /Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
from /Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
from /Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
from /Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/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/ruby-2.0.0-rc1@global/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
from /Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require'
from /Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
from /Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require'
from /Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/gems/railties-3.2.13/lib/rails/application.rb:103:in `require_environment!'
from /Users/tn/.rvm/gems/ruby-2.0.0-rc1@global/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
非常感谢任何帮助!
答案 0 :(得分:2)
确实是你的路线档案:
root to: "root_path"
这应该是这样的:
root to: "controller#action"
root_path
是Rails在路由文件中有root
定义时自动生成的帮助名称。