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

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


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


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'


Changeroot 'landing/index'toroot 'landing#index'