Rake route Error "Missing :action key on routes definition"

You can do it many ways, these all work:

  • get 'script/index'
  • get 'script/index' => 'script#index'
  • get 'script/index', to: 'script#index'

Think of path first and controller#method to follow.

Root is a special case, always: root 'script#index'


I had the same error running rails g.

If you run a command that uses routes.rb, the file needs to be error free for the command to work.

In your case, you had paths, but you didn't match them to actions, so the routes.rb file was broken. You needed something like get 'landing/index' => 'my_controller#my_action'


Change root 'landing/index' to root 'landing#index'


The Rails router recognizes URLs and dispatches them to a controller's action. The error is caused by missing out the mapped action.

Rails.application.routes.draw do
  #   url               action
  get 'script/index' => 'script#index'
  get 'landing/index' => 'landing#index'
  root 'script#index'
end