سؤال

Bit new to rails, but I was generating some controllers, I did one, then went to do another and it spit out an error:

c:\row\dev\a>rails generate controller Person name:string
C:/row/ruby200/lib/ruby/gems/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/rou
ting/mapper.rb:229:in `default_controller_and_action': missing :controller (Argu
mentError)

I tried rubymine just to see and it pretty much just did the same thing, that full list of what it outputted is below. I've never had it just decide to stop generating controllers like that, and I did add something to the routes file because I saw a link that said the routes file might need root to: 'controller#action' though i've never had to include that in the route file to generate a controller before, but that didn't fix it either. That was the only other thing I could find online with a similar problem. Any thoughts?

C:\row\Ruby200\bin\ruby.exe -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) C:/row/dev/a/bin/rails generate controller person name:string -s
C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:229:in `default_controller_and_action': missing :controller (ArgumentError)
    from C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:116:in `normalize_options!'
    from C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:64:in `initialize'
    from C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1443:in `new'
    from C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1443:in `add_route'
    from C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1422:in `decomposed_match'
    from C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1403:in `block in match'
    from C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1394:in `each'
    from C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:1394:in `match'
    from C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:601:in `map_method'
    from C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/mapper.rb:562:in `get'
    from C:/row/dev/a/config/routes.rb:2:in `block in <top (required)>'
    from C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:341:in `instance_exec'
    from C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:341:in `eval_block'
    from C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:319:in `draw'
    from C:/row/dev/a/config/routes.rb:1:in `<top (required)>'
    from C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `load'
    from C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `block in load'
    from C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
    from C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `load'
    from C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
    from C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:40:in `each'
    from C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:40:in `load_paths'
    from C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:16:in `reload!'
    from C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:26:in `block in updater'
    from C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/file_update_checker.rb:75:in `call'
    from C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/file_update_checker.rb:75:in `execute'
    from C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/application/routes_reloader.rb:27:in `updater'
    from C:131071:in `execute_if_updated'
    from C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'
    from C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/initializable.rb:30:in `instance_exec'
    from C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/initializable.rb:30:in `run'
    from C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/initializable.rb:55:in `block in run_initializers'
    from C:/row/Ruby200/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'
    from C:/row/Ruby200/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
    from C:/row/Ruby200/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'
    from C:/row/Ruby200/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'
    from C:/row/Ruby200/lib/ruby/2.0.0/tsort.rb:180:in `each'
    from C:/row/Ruby200/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'
    from C:/row/Ruby200/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'
    from C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/initializable.rb:54:in `run_initializers'
    from C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/application.rb:215:in `initialize!'
    from C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from C:/row/dev/a/config/environment.rb:5:in `<top (required)>'
    from C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/application.rb:189:in `require'
    from C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/application.rb:189:in `require_environment!'
    from C:/row/Ruby200/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/commands.rb:44:in `<top (required)>'
    from C:/row/dev/a/bin/rails:4:in `require'
    from C:/row/dev/a/bin/rails:4:in `<top (required)>'
    from -e:1:in `load'
    from -e:1:in `<main>'

Process finished with exit code 1
هل كانت مفيدة؟

المحلول

For Generating a controller you specified with method name not variable

like

rails generate controller Person index show 

I hope you understand and it work for you.

Thanks.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top