2010-12-31 9 views
28

Soy Ruby nuby (y nuevo en Stack Overflow) trabajando en el Rails Tutorial by Michael Hartl y de repente mi servidor de desarrollo won't load and keeps exiting. La consola tampoco se carga y Rspec especifica/produce errores/excepciones. Incluyo algunos resultados de la terminal, su ayuda es muy apreciada.¿Por qué mi servidor de desarrollo no se está cargando? default_controller_and_action ': missing: action (ArgumentError)

Exiting 
/Users/ameedachowdhury/.rvm/gems/[email protected]/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:164:in `default_controller_and_action': missing :action (ArgumentError) 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:68:in `normalize_options!' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:51:in `initialize' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:261:in `new' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:261:in `match' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:1112:in `match' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:1297:in `match' 
    from /Users/ameedachowdhury/rails_projects/railstutorial/config/routes.rb:11:in `block in <top (required)>' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:233:in `instance_exec' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:233:in `draw' 
    from /Users/ameedachowdhury/rails_projects/railstutorial/config/routes.rb:1:in `<top (required)>' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `load' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `block in load' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in `block in load_dependency' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:596:in `new_constants_in' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in `load_dependency' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `load' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/railties-3.0.3/lib/rails/application.rb:127:in `block in reload_routes!' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/railties-3.0.3/lib/rails/application.rb:127:in `each' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/railties-3.0.3/lib/rails/application.rb:127:in `reload_routes!' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/railties-3.0.3/lib/rails/application.rb:120:in `block in routes_reloader' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/activesupport-3.0.3/lib/active_support/file_update_checker.rb:32:in `call' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/activesupport-3.0.3/lib/active_support/file_update_checker.rb:32:in `execute_if_updated' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/railties-3.0.3/lib/rails/application/finisher.rb:51:in `block (2 levels) in <module:Finisher>' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/railties-3.0.3/lib/rails/application/finisher.rb:52:in `call' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/railties-3.0.3/lib/rails/application/finisher.rb:52:in `block in <module:Finisher>' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `instance_exec' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `run' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/railties-3.0.3/lib/rails/initializable.rb:50:in `block in run_initializers' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `each' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `run_initializers' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/railties-3.0.3/lib/rails/application.rb:134:in `initialize!' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/railties-3.0.3/lib/rails/application.rb:77:in `method_missing' 
    from /Users/ameedachowdhury/rails_projects/railstutorial/config/environment.rb:5:in `<top (required)>' 
    from /Users/ameedachowdhury/rails_projects/railstutorial/config.ru:3:in `require' 
    from /Users/ameedachowdhury/rails_projects/railstutorial/config.ru:3:in `block in <main>' 
    from /Users/ameedachowdhury/.rvm/gems/ruby-1.[email protected]/gems/rack-1.2.1/lib/rack/builder.rb:46:in `instance_eval' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/rack-1.2.1/lib/rack/builder.rb:46:in `initialize' 
    from /Users/ameedachowdhury/rails_projects/railstutorial/config.ru:1:in `new' 
    from /Users/ameedachowdhury/rails_projects/railstutorial/config.ru:1:in `<main>' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/rack-1.2.1/lib/rack/builder.rb:35:in `eval' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/rack-1.2.1/lib/rack/builder.rb:35:in `parse_file' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/rack-1.2.1/lib/rack/server.rb:162:in `app' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/rack-1.2.1/lib/rack/server.rb:248:in `wrapped_app' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/rack-1.2.1/lib/rack/server.rb:213:in `start' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/railties-3.0.3/lib/rails/commands/server.rb:65:in `start' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/railties-3.0.3/lib/rails/commands.rb:30:in `block in <top (required)>' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/railties-3.0.3/lib/rails/commands.rb:27:in `tap' 
    from /Users/ameedachowdhury/.rvm/gems/[email protected]/gems/railties-3.0.3/lib/rails/commands.rb:27:in `<top (required)>' 
    from script/rails:6:in `require' 
    from script/rails:6:in `<main>' 
ameeda-chowdhurys-macbook:railstutorial ameedachowdhury$ 

Respuesta

69

Cuando me encontré con este problema, que era porque una de las rutas en routes.rb tenían una barra (/) en lugar de la almohadilla (#) cuando se utiliza la sintaxis controller#action (utilicé "controlador/acción ", que era incorrecta).

Por ejemplo, accidentalmente tuve root :to => 'home/index'. Se suponía que era root :to => 'home#index'.

Encontré esta solución en here.

+3

El ol 'slash en lugar del problema hash – Catfish

0

En mi caso fue causado por el sufijo slash '/' en algunas de mis rutas. P.ej.

post 'load_query/' 

Después de la eliminación de este sufijo a

post 'load_query' 

funcionó.

8

Esto es causado por rutas incorrectas -
¡Compruebe su configuración/routes.rb, incluso si una ruta mencionada es incorrecta, entonces se produce este error!
También asegúrese de que la ruta es

'/url/for/something' => 'controller#action' 

o

root :to => 'controller#action 
+0

esta es la solución, gracias. es posible que tenga el mismo error que tuve, voy a seguir el mismo tutorial. simplemente comente la última versión cruda modificada en routes.rb y verá qué ruta causa el error, luego corrija la sintaxis. – YogiZoli

2

también soy Rubí nuby y tenía el mismo error mientras se trabaja en el Tutorial de rieles de Michael Hartl. Si eres como yo, podrías estar simplemente escribiendo todo el código que aparece en el libro con realmente leer o entender el texto. No todo es paso a paso. En demostrando caso camello vs. caso serpiente Hartl muestra una caja con el siguiente código

$ rails generate controller static_pages ... 

Aquí, Hartl está simplemente tratando de contrastar instrucciones para generar un controlador StaticPages usando caso serpiente, en lugar de caso camello, que fue hecho en Listado 3.4. Los puntos "..." son simplemente para editar o truncar el resto de las instrucciones para la línea de cmd. He escrito exactamente de lo que se muestra y terminó con la siguiente en mis rutas del archivo:

SampleApp::Application.routes.draw do 
get "static_pages/..." 

get "static_pages/home" 

get "static_pages/help" 

abren el archivo de rutas, elimine

get "static_pages/..." 

guardar el archivo de rutas, e intente iniciar el servidor rieles de nuevo .

También destruí "rails generate controller static_pages ..." No estoy seguro si eso tuvo algún efecto, pero ahora todo funciona.

1

Por defecto conseguir esto:

Rails.application.routes.draw do 
    get 'static_pages/...' 

    get 'static_pages/home' 

    get 'static_pages/help' 

BORRAR Sólo esto:

get 'static_pages/...' 

Y TENDRAS esto en el archivo routes.rb

Rails.application.routes.draw do 

    get 'static_pages/home' 

    get 'static_pages/help' 
0

cambio de su raíz predeterminado en el archivo routes.rb.

get "static_pages#home" TO root to: 'static_pages#home' 

He pasado por el mismo problema, y ​​el cambio anterior trabajó para mí.

Cuestiones relacionadas