Edited at

rails db:migrateでエラーになったときのメモ

More than 3 years have passed since last update.

rails db:migrateをしたら、エラーが吐かれました。

エラー全文はページ下部に表示しますが、以下の1文が怪しいと感じ、routes.rbを調べてみました。

ArgumentError: Missing :controller key on routes definition, please check your routes.


routes.rb

Rails.application.routes.draw do

root 'pages#index'

get 'pages#show'

devise_for :admin_users

# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end


今まであまり気にしてこなかったのですが、rootのみ特別で、コントローラーとアクションの間に#を入れるのですね。。。

rootではないshow#を入れていた。)

参考資料:ルート(/)へのルーティング設定

そのため、下記のように修正しました。


routes.rb

-  get 'pages#show'

+ get 'pages/show'

再度マイグレーションを実行したところ、うまくいきました。


補足

こちらのページを作成した方もマイグレーションを実行する際に、bundleでエラーになったようです。

「rake db:migrate」コマンドで「rake aborted」になったら


エラー全文

rails aborted!

ArgumentError: Missing :controller key on routes definition, please check your routes.
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/routing/mapper.rb:328:in `check_part'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/routing/mapper.rb:308:in `check_controller_and_action'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/routing/mapper.rb:251:in `normalize_options!'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/routing/mapper.rb:115:in `initialize'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/routing/mapper.rb:68:in `new'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/routing/mapper.rb:68:in `build'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/routing/mapper.rb:1698:in `add_route'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/routing/mapper.rb:1670:in `decomposed_match'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/routing/mapper.rb:1634:in `block in match'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/routing/mapper.rb:1617:in `each'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/routing/mapper.rb:1617:in `match'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/routing/mapper.rb:722:in `map_method'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/routing/mapper.rb:680:in `get'
/Users/user/rails_devise/config/routes.rb:5:in `block in <top (required)>'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/routing/route_set.rb:389:in `instance_exec'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/routing/route_set.rb:389:in `eval_block'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/routing/route_set.rb:371:in `draw'
/Users/user/rails_devise/config/routes.rb:1:in `<top (required)>'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `load'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `block in load'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `load'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/railties-5.0.0.1/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/railties-5.0.0.1/lib/rails/application/routes_reloader.rb:40:in `each'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/railties-5.0.0.1/lib/rails/application/routes_reloader.rb:40:in `load_paths'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/railties-5.0.0.1/lib/rails/application/routes_reloader.rb:16:in `reload!'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/railties-5.0.0.1/lib/rails/application/routes_reloader.rb:26:in `block in updater'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/file_update_checker.rb:77:in `execute'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/railties-5.0.0.1/lib/rails/application/routes_reloader.rb:27:in `updater'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/railties-5.0.0.1/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/railties-5.0.0.1/lib/rails/application/finisher.rb:119:in `block in <module:Finisher>'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/railties-5.0.0.1/lib/rails/initializable.rb:30:in `instance_exec'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/railties-5.0.0.1/lib/rails/initializable.rb:30:in `run'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/railties-5.0.0.1/lib/rails/initializable.rb:55:in `block in run_initializers'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/railties-5.0.0.1/lib/rails/initializable.rb:54:in `run_initializers'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/railties-5.0.0.1/lib/rails/application.rb:352:in `initialize!'
/Users/user/rails_devise/config/environment.rb:5:in `<top (required)>'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/railties-5.0.0.1/lib/rails/application.rb:328:in `require_environment!'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/railties-5.0.0.1/lib/rails/application.rb:448:in `block in run_tasks_blocks'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/railties-5.0.0.1/lib/rails/commands/rake_proxy.rb:13:in `block in run_rake_task'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/railties-5.0.0.1/lib/rails/commands/rake_proxy.rb:10:in `run_rake_task'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:51:in `run_command!'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in `<top (required)>'
/Users/user/rails_devise/bin/rails:9:in `require'
/Users/user/rails_devise/bin/rails:9:in `<top (required)>'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/spring-1.7.2/lib/spring/client/rails.rb:28:in `load'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/spring-1.7.2/lib/spring/client/rails.rb:28:in `call'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/spring-1.7.2/lib/spring/client/command.rb:7:in `call'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/spring-1.7.2/lib/spring/client.rb:30:in `run'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/spring-1.7.2/bin/spring:49:in `<top (required)>'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/spring-1.7.2/lib/spring/binstub.rb:11:in `load'
/Users/user/rails_devise/vendor/bundle/ruby/2.3.0/gems/spring-1.7.2/lib/spring/binstub.rb:11:in `<top (required)>'
/Users/user/rails_devise/bin/spring:13:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)