Search code examples
ruby-on-railsrubyroutesconfigdbmigrate

Does not find the right Route(routes)


Hello i am having a problem when i try to do bundle exec rake db:migrate i never had this problem and this is the code

bundle exec rake db:migraterake aborted!
ArgumentError: Missing :controller key on routes definition, please check your routes.
/usr/local/rvm/gems/ruby-2.2.1/gems/actionpack-4.2.2/lib/action_dispatch/routing/mapper.rb:275:in `check_part'
/usr/local/rvm/gems/ruby-2.2.1/gems/actionpack-4.2.2/lib/action_dispatch/routing/mapper.rb:255:in `check_controller_and_action'
/usr/local/rvm/gems/ruby-2.2.1/gems/actionpack-4.2.2/lib/action_dispatch/routing/mapper.rb:178:in `normalize_options!'
/usr/local/rvm/gems/ruby-2.2.1/gems/actionpack-4.2.2/lib/action_dispatch/routing/mapper.rb:100:in `initialize'
/usr/local/rvm/gems/ruby-2.2.1/gems/actionpack-4.2.2/lib/action_dispatch/routing/mapper.rb:78:in `new'
/usr/local/rvm/gems/ruby-2.2.1/gems/actionpack-4.2.2/lib/action_dispatch/routing/mapper.rb:78:in `build'
/usr/local/rvm/gems/ruby-2.2.1/gems/actionpack-4.2.2/lib/action_dispatch/routing/mapper.rb:1559:in `add_route'
/usr/local/rvm/gems/ruby-2.2.1/gems/actionpack-4.2.2/lib/action_dispatch/routing/mapper.rb:1536:in `decomposed_match'
/usr/local/rvm/gems/ruby-2.2.1/gems/actionpack-4.2.2/lib/action_dispatch/routing/mapper.rb:1517:in `block in match'
/usr/local/rvm/gems/ruby-2.2.1/gems/actionpack-4.2.2/lib/action_dispatch/routing/mapper.rb:1507:in `each'
/usr/local/rvm/gems/ruby-2.2.1/gems/actionpack-4.2.2/lib/action_dispatch/routing/mapper.rb:1507:in `match'
/usr/local/rvm/gems/ruby-2.2.1/gems/actionpack-4.2.2/lib/action_dispatch/routing/mapper.rb:689:in `map_method'
/usr/local/rvm/gems/ruby-2.2.1/gems/actionpack-4.2.2/lib/action_dispatch/routing/mapper.rb:650:in `get'
/home/ubuntu/workspace/sample_app/config/routes.rb:3:in `block in <top (required)>'
/usr/local/rvm/gems/ruby-2.2.1/gems/actionpack-4.2.2/lib/action_dispatch/routing/route_set.rb:432:in `instance_exec'
/usr/local/rvm/gems/ruby-2.2.1/gems/actionpack-4.2.2/lib/action_dispatch/routing/route_set.rb:432:in `eval_block'
/usr/local/rvm/gems/ruby-2.2.1/gems/actionpack-4.2.2/lib/action_dispatch/routing/route_set.rb:410:in `draw'
/home/ubuntu/workspace/sample_app/config/routes.rb:1:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:268:in `load'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:268:in `block in load'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:240:in `load_dependency'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:268:in `load'
/usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.2/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
/usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.2/lib/rails/application/routes_reloader.rb:40:in `each'
/usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.2/lib/rails/application/routes_reloader.rb:40:in `load_paths'
/usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.2/lib/rails/application/routes_reloader.rb:16:in `reload!'
/usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.2/lib/rails/application/routes_reloader.rb:26:in `block in updater'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.2/lib/active_support/file_update_checker.rb:75:in `call'
/usr/local/rvm/gems/ruby-2.2.1/gems/activesupport-4.2.2/lib/active_support/file_update_checker.rb:75:in `execute'
/usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.2/lib/rails/application/routes_reloader.rb:27:in `updater'
/usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.2/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
/usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.2/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'
/usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.2/lib/rails/initializable.rb:30:in `instance_exec'
/usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.2/lib/rails/initializable.rb:30:in `run'
/usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.2/lib/rails/initializable.rb:55:in `block in run_initializers'
/usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.2/lib/rails/initializable.rb:54:in `run_initializers'
/usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.2/lib/rails/application.rb:352:in `initialize!'
/home/ubuntu/workspace/sample_app/config/environment.rb:5:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.2/lib/rails/application.rb:328:in `require'
/usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.2/lib/rails/application.rb:328:in `require_environment!'
/usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.2/lib/rails/application.rb:457:in `block in run_tasks_blocks'
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)

This is the first part i did rails generate controller AccountActivations \ edit --no-test-framework

Then routes.rb

Rails.application.routes.draw do

  get 'account_activations/ edit'

  get 'account_activation/ edit'

  get 'sessions/new'

  root                 'static_pages#home'
  get 'help'        => 'static_pages#help'
  get 'about'       => 'static_pages#about'
  get 'contact'     => 'static_pages#contact'
  get 'signup'      => 'users#new'
  get 'login'       => 'sessions#new'
  post 'login'      => 'sessions#create'
  delete 'logout'   => 'sessions#destroy'
  resources :users
  resources :account_activations, only: [:edit] 
end

then i run this code :

$ rails generate migration add_activation_to_users \
> activation_digest:string activated:boolean activated_at:datetime

i modify this new file

class AddActivationToUsers < ActiveRecord::Migration
  def change
    add_column :users, :activation_digest, :string
    add_column :users, :activated, :boolean, default: false
    add_column :users, :activated_at, :datetime
end end

and finally bundle exec rake db:migrate Then i get the error message, does anyone see any problem? thanks in advance! By the way this is chapter 10 ruby on rails tutorial.


Solution

  • the help and about route missing it's controller (optionally action) parameter.

    Also the root route is missing it's options.