我使用rails 4.2.6在我的Mac上的rails应用程序上创建了一个ruby,并在终端中键入rails server
。看起来很好,直到我在Google Chrome中使用localhost:3000。
错误是:
localhost 拒绝连接
ERR_CONNECTION_REFUSED
我在终端输入rails s
时得到的输出是:
=> Booting WEBrick
=> Rails 4.2.6 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
/Users/kids/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.6/lib/action_dispatch/routing/mapper.rb:275:in `check_part': Missing :controller key on routes definition, please check your routes. (ArgumentError)
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.6/lib/action_dispatch/routing/mapper.rb:255:in `check_controller_and_action'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.6/lib/action_dispatch/routing/mapper.rb:178:in `normalize_options!'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.6/lib/action_dispatch/routing/mapper.rb:100:in `initialize'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.6/lib/action_dispatch/routing/mapper.rb:78:in `new'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.6/lib/action_dispatch/routing/mapper.rb:78:in `build'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.6/lib/action_dispatch/routing/mapper.rb:1560:in `add_route'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.6/lib/action_dispatch/routing/mapper.rb:1537:in `decomposed_match'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.6/lib/action_dispatch/routing/mapper.rb:1518:in `block in match'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.6/lib/action_dispatch/routing/mapper.rb:1508:in `each'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.6/lib/action_dispatch/routing/mapper.rb:1508:in `match'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.6/lib/action_dispatch/routing/mapper.rb:690:in `map_method'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.6/lib/action_dispatch/routing/mapper.rb:651:in `get'
from /Users/kids/Desktop/PythonApp/config/routes.rb:2:in `block in <top (required)>'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.6/lib/action_dispatch/routing/route_set.rb:432:in `instance_exec'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.6/lib/action_dispatch/routing/route_set.rb:432:in `eval_block'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.6/lib/action_dispatch/routing/route_set.rb:410:in `draw'
from /Users/kids/Desktop/PythonApp/config/routes.rb:1:in `<top (required)>'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `load'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `block in load'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `load'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/application/routes_reloader.rb:40:in `each'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/application/routes_reloader.rb:40:in `load_paths'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/application/routes_reloader.rb:16:in `reload!'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/application/routes_reloader.rb:26:in `block in updater'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.6/lib/active_support/file_update_checker.rb:75:in `call'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.6/lib/active_support/file_update_checker.rb:75:in `execute'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/application/routes_reloader.rb:27:in `updater'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/initializable.rb:30:in `run'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/kids/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:226:in `block in tsort_each'
from /Users/kids/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
from /Users/kids/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:429:in `each_strongly_connected_component_from'
from /Users/kids/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:347:in `block in each_strongly_connected_component'
from /Users/kids/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:345:in `each'
from /Users/kids/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:345:in `call'
from /Users/kids/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:345:in `each_strongly_connected_component'
from /Users/kids/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:224:in `tsort_each'
from /Users/kids/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/tsort.rb:203:in `tsort_each'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/application.rb:352:in `initialize!'
from /Users/kids/Desktop/PythonApp/config/environment.rb:5:in `<top (required)>'
from /Users/kids/Desktop/PythonApp/config.ru:3:in `require'
from /Users/kids/Desktop/PythonApp/config.ru:3:in `block in <main>'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/builder.rb:55:in `instance_eval'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/builder.rb:55:in `initialize'
from /Users/kids/Desktop/PythonApp/config.ru:in `new'
from /Users/kids/Desktop/PythonApp/config.ru:in `<main>'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/builder.rb:49:in `eval'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/builder.rb:49:in `new_from_string'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/builder.rb:40:in `parse_file'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/server.rb:299:in `build_app_and_options_from_config'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/server.rb:208:in `app'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/commands/server.rb:61:in `app'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/server.rb:336:in `wrapped_app'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/commands/server.rb:139:in `log_to_stdout'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/commands/server.rb:78:in `start'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:80:in `block in server'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:75:in `tap'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:75:in `server'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/commands.rb:17:in `<top (required)>'
from /Users/kids/Desktop/PythonApp/bin/rails:9:in `require'
from /Users/kids/Desktop/PythonApp/bin/rails:9:in `<top (required)>'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/spring-1.6.4/lib/spring/client/rails.rb:28:in `load'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/spring-1.6.4/lib/spring/client/rails.rb:28:in `call'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/spring-1.6.4/lib/spring/client/command.rb:7:in `call'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/spring-1.6.4/lib/spring/client.rb:28:in `run'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/spring-1.6.4/bin/spring:49:in `<top (required)>'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/spring-1.6.4/lib/spring/binstub.rb:11:in `load'
from /Users/kids/.rvm/gems/ruby-2.2.1/gems/spring-1.6.4/lib/spring/binstub.rb:11:in `<top (required)>'
from /Users/kids/Desktop/PythonApp/bin/spring:13:in `require'
from /Users/kids/Desktop/PythonApp/bin/spring:13:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
这是我的路线档案:
Rails.application.routes.draw do
get '/index' => 'welcome#index'
get '/' => 'welcome#index'
get '/welcome' => 'welcome#index'
get 'signup' => 'users#new'
resources :users
get '/learn/' => 'learn#hub'
get '/login' => 'sessions#new'
post 'login' => 'sessions#create'
get '/logout' => 'sessions#destroy'
delete 'logout' => 'sessions#destroy'
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
# root 'welcome#index'
# Example of regular route:
# get 'products/:id' => 'catalog#view'
# Example of named route that can be invoked with purchase_url(id: product.id)
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
# Example resource route (maps HTTP verbs to controller actions automatically):
# resources :products
# Example resource route with options:
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end
# Example resource route with sub-resources:
# resources :products do
# resources :comments, :sales
# resource :seller
# end
# Example resource route with more complex sub-resources:
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', on: :collection
# end
# end
# Example resource route with concerns:
# concern :toggleable do
# post 'toggle'
# end
# resources :posts, concerns: :toggleable
# resources :photos, concerns: :toggleable
# Example resource route within a namespace:
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
end
当我尝试rake路线时,它说:
rake aborted!
ArgumentError: Missing :controller key on routes definition, please check your routes.
/Users/kids/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.6/lib/action_dispatch/routing/mapper.rb:275:in `check_part'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.6/lib/action_dispatch/routing/mapper.rb:255:in `check_controller_and_action'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.6/lib/action_dispatch/routing/mapper.rb:178:in `normalize_options!'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.6/lib/action_dispatch/routing/mapper.rb:100:in `initialize'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.6/lib/action_dispatch/routing/mapper.rb:78:in `new'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.6/lib/action_dispatch/routing/mapper.rb:78:in `build'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.6/lib/action_dispatch/routing/mapper.rb:1560:in `add_route'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.6/lib/action_dispatch/routing/mapper.rb:1537:in `decomposed_match'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.6/lib/action_dispatch/routing/mapper.rb:1518:in `block in match'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.6/lib/action_dispatch/routing/mapper.rb:1508:in `each'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.6/lib/action_dispatch/routing/mapper.rb:1508:in `match'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.6/lib/action_dispatch/routing/mapper.rb:690:in `map_method'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.6/lib/action_dispatch/routing/mapper.rb:651:in `get'
/Users/kids/Desktop/PythonApp/config/routes.rb:2:in `block in <top (required)>'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.6/lib/action_dispatch/routing/route_set.rb:432:in `instance_exec'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.6/lib/action_dispatch/routing/route_set.rb:432:in `eval_block'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.6/lib/action_dispatch/routing/route_set.rb:410:in `draw'
/Users/kids/Desktop/PythonApp/config/routes.rb:1:in `<top (required)>'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `load'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `block in load'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:240:in `load_dependency'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.6/lib/active_support/dependencies.rb:268:in `load'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/application/routes_reloader.rb:40:in `each'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/application/routes_reloader.rb:40:in `load_paths'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/application/routes_reloader.rb:16:in `reload!'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/application/routes_reloader.rb:26:in `block in updater'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.6/lib/active_support/file_update_checker.rb:75:in `call'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/activesupport-4.2.6/lib/active_support/file_update_checker.rb:75:in `execute'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/application/routes_reloader.rb:27:in `updater'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/initializable.rb:30:in `instance_exec'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/initializable.rb:30:in `run'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/initializable.rb:55:in `block in run_initializers'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/initializable.rb:54:in `run_initializers'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/application.rb:352:in `initialize!'
/Users/kids/Desktop/PythonApp/config/environment.rb:5:in `<top (required)>'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/application.rb:328:in `require'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/application.rb:328:in `require_environment!'
/Users/kids/.rvm/gems/ruby-2.2.1/gems/railties-4.2.6/lib/rails/application.rb:457:in `block in run_tasks_blocks'
Tasks: TOP => routes => environment
(See full trace by running task with --trace)
答案 0 :(得分:0)
我搞砸了其中一个控制器和路径文件。都好。它工作!!!