设置rails应用程序的问题。它第一次工作,但后来当我重新打开它,并试图运行'rails服务器'它不工作,并返回以下错误。谢谢。
我正在使用Ruby 2.3.1p112 Rails 5.0 MySQL 5.7.13 $ Rails服务器
=> Boot Puma
=> Rails 5.0.0应用程序在http://localhost:3000上开始开发
=>运行rails server -h
获取更多启动选项正在退出
/Users/布鲁斯/sea/config/routes.rb:6:in `<top(required)':undefined
main:Object的方法“root”(NoMethodError)
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/activesupport-
字符串
5.0.0/lib/active_support/dependencies.rb:287:in `load'
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/activesupport-
型
5.0.0/lib/active_support/dependencies.rb:287:in `block in load'
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/activesupport-
型
5.0.0/lib/active_support/dependencies.rb:259:in `load_dependencies '
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/activesupport-
型
5.0.0/lib/active_support/dependencies.rb:287:in `load'
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/railties-5.0.0/lib
型
/rails/application/routes_reloader.rb:40:in `block in load_paths'
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/railties-5.0.0/lib
型
/rails/application/routes_reloader.rb:40:in `each'
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/railties-5.0.0/lib
型
/rails/application/routes_reloader.rb:40:in `load_paths'
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/railties-5.0.0/lib
型
/rails/application/routes_reloader.rb:16:in `reload!'
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/railties-5.0.0/lib
型
/rails/application/routes_reloader.rb:26:in `block in updater'
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/activesupport-
型
5.0.0/lib/active_support/file_update_checker.rb:77:in `execute'
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/railties-5.0.0/lib
型
/rails/application/routes_reloader.rb:27:in `updater'
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/railties-5.0.0/lib
型
/rails/application/routes_reloader.rb:7:in `execute_if_updated'
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/railties-5.0.0/lib
型
/rails/application/finisher.rb:119:in `block in module:Finisher'
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/railties-5.0.0/lib
型
/rails/initializable.rb:30:在`instance_exec'中
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/railties-5.0.0/lib
型
/rails/initializable.rb:30:in 'run'
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/railties-5.0.0/lib
型
/rails/initializable.rb:55:in `block in run_initializers'
from /Users/bruce/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0
型
/tsort.rb:228:in `block in tsort_each'
from /Users/bruce/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0
型
/tsort.rb:350:in `block(2 levels)in each_strongly_connected_component'
from /Users/bruce/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0
型
/tsort.rb:431:在`each_strongly_connected_component_from'中
from /Users/bruce/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0
型
/tsort.rb:349:in `block in each_strongly_connected_component'
from /Users/bruce/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0
型
/tsort.rb:347:在`each'中
from /Users/bruce/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0
/tsort.rb:347:in `call'
from /Users/bruce/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0
/tsort.rb:347:在`each_strong_connected_component'中
from /Users/bruce/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0
/tsort.rb:226:在`tsort_each'中
from /Users/bruce/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0
/tsort.rb:205:在`tsort_each'中
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/railties-5.0.0/lib
/rails/initializable.rb:54:in `run_initializers'
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/railties-5.0.0/lib
型
/rails/application.rb:352:in `initialize!'
from /Users/bruce/sea/config/environment.rb:5:in `<top (required)>'
from /Users/bruce/sea/config.ru:3:in `require_relative'
from /Users/bruce/sea/config.ru:3:in `block in <main>'
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/rack-2.0.1/lib
型
/rack/builder.rb:55:在`instance_eval'中
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/rack-2.0.1/lib
型
/rack/builder.rb:55:in `initialize'
from /Users/bruce/sea/config.ru:in `new'
from /Users/bruce/sea/config.ru:in `<main>'
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/rack-2.0.1/lib
型
/rack/builder.rb:49:在`eval'中
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/rack-2.0.1/lib
型
/rack/builder.rb:49:in `new_from_string'
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/rack-2.0.1/lib
型
/rack/builder.rb:40:在`parse_file'中
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/rack-2.0.1/lib
/rack/server.rb:318:在`build_app_and_options_from_config'中
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/rack-2.0.1/lib
/rack/server.rb:218:in `app'
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/railties-5.0.0/lib
/rails/commands/server.rb:59:in `app'
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/rack-2.0.1/lib
/rack/server.rb:353:在`wrapped_app'中
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/railties-5.0.0/lib
/rails/commands/server.rb:124:in `log_to_stdout'
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/railties-5.0.0/lib
/rails/commands/server.rb:77:in `start'
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/railties-5.0.0/lib
/rails/commands/commands_tasks.rb:90:in `block in server'
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/railties-5.0.0/lib
/rails/commands/commands_tasks.rb:85:in `tap'
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/railties-5.0.0/lib
/rails/commands/commands_tasks.rb:85:in `server'
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/railties-5.0.0/lib
/rails/commands/commands_tasks.rb:49:in `run_command!'
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/railties-5.0.0/lib
/rails/commands.rb:18:in `<top(required)>'
from /Users/bruce/sea/bin/rails:9:in `require'
from /Users/bruce/sea/bin/rails:9:in `<top (required)>'
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/spring-1.7.2/lib
/spring/client/rails.rb:28:in `load'
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/spring-1.7.2/lib
/spring/client/rails.rb:28:in `call'
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/spring-1.7.2/lib
/spring/client/command.rb:7:in `call'
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/spring-1.7.2/lib
/spring/client.rb:30:in `run'
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/spring-1.7.2/bin
/spring:49:in `<top(required)>'
from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/spring-1.7.2/lib
/spring/binstub.rb:11:in load' 来自/Users/布鲁斯/.rvm/gems/ruby-2.3.1@global/gems/spring-1.7.2/lib /spring/binstub.rb:11:in
<top(required)>'
from /Users/bruce/sea/bin/spring:13:in `require'
from /Users/bruce/sea/bin/spring:13:in `<top (required)>'
from bin/rails:3:in `load'`enter
from bin/rails:3:in `<main>'
1条答案
按热度按时间pkln4tw61#
看起来在你的routes.rb文件中你错误地使用了
root
。尝试将其更改为root_url
。在ruby中,如果在任何位置都没有找到任何东西,那么它将显示没有方法错误,因为mainObject是一个基类。希望这对你有帮助。