前提・実現したいこと
Ruby on rails のチュートリアルを進めています。
第7章のユーザーページの作成を進めている時に問題が発生しました。(7章での作業が関連しているかは不明です。)
rails server の起動時にエラーが発生しサーバーが起動できなくなりました。
発生している問題・エラーメッセージ
/config/routes.rb:9:in <top (required)>': undefined local variable or method
' for main:Object (NameError)
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/activesupport-5.1.5/lib/active_support/dependencies.rb:286:in load' from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/activesupport-5.1.5/lib/active_support/dependencies.rb:286:in
block in load'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/activesupport-5.1.5/lib/active_support/dependencies.rb:258:in load_dependency' from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/activesupport-5.1.5/lib/active_support/dependencies.rb:286:in
load'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.1.5/lib/rails/application/routes_reloader.rb:55:in block in load_paths' from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.1.5/lib/rails/application/routes_reloader.rb:55:in
each'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.1.5/lib/rails/application/routes_reloader.rb:55:in load_paths' from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.1.5/lib/rails/application/routes_reloader.rb:18:in
reload!'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.1.5/lib/rails/application/routes_reloader.rb:41:in block in updater' from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/activesupport-5.1.5/lib/active_support/file_update_checker.rb:81:in
execute'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.1.5/lib/rails/application/routes_reloader.rb:42:in updater' from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.1.5/lib/rails/application/routes_reloader.rb:31:in
execute_if_updated'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.1.5/lib/rails/application/finisher.rb:128:in block in <module:Finisher>' from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.1.5/lib/rails/initializable.rb:30:in
instance_exec'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.1.5/lib/rails/initializable.rb:30:in run' from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.1.5/lib/rails/initializable.rb:59:in
block in run_initializers'
from C:/Ruby24-x64/lib/ruby/2.4.0/tsort.rb:228:in block in tsort_each' from C:/Ruby24-x64/lib/ruby/2.4.0/tsort.rb:350:in
block (2 levels) in each_strongly_connected_component'
from C:/Ruby24-x64/lib/ruby/2.4.0/tsort.rb:431:in each_strongly_connected_component_from' from C:/Ruby24-x64/lib/ruby/2.4.0/tsort.rb:349:in
block in each_strongly_connected_component'
from C:/Ruby24-x64/lib/ruby/2.4.0/tsort.rb:347:in each' from C:/Ruby24-x64/lib/ruby/2.4.0/tsort.rb:347:in
call'
from C:/Ruby24-x64/lib/ruby/2.4.0/tsort.rb:347:in each_strongly_connected_component' from C:/Ruby24-x64/lib/ruby/2.4.0/tsort.rb:226:in
tsort_each'
from C:/Ruby24-x64/lib/ruby/2.4.0/tsort.rb:205:in tsort_each' from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.1.5/lib/rails/initializable.rb:58:in
run_initializers'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.1.5/lib/rails/application.rb:353:in initialize!' from C:/Users/riis3/Desktop/railsapp/config/environment.rb:5:in
<top (required)>'
from config.ru:3:in require_relative' from config.ru:3:in
block in <main>'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rack-2.0.4/lib/rack/builder.rb:55:in instance_eval' from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rack-2.0.4/lib/rack/builder.rb:55:in
initialize'
from config.ru:in new' from config.ru:in
<main>'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rack-2.0.4/lib/rack/builder.rb:49:in eval' from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rack-2.0.4/lib/rack/builder.rb:49:in
new_from_string'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rack-2.0.4/lib/rack/builder.rb:40:in parse_file' from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rack-2.0.4/lib/rack/server.rb:319:in
build_app_and_options_from_config'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rack-2.0.4/lib/rack/server.rb:219:in app' from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.1.5/lib/rails/commands/server/server_command.rb:24:in
app'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/rack-2.0.4/lib/rack/server.rb:354:in wrapped_app' from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.1.5/lib/rails/commands/server/server_command.rb:80:in
log_to_stdout'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.1.5/lib/rails/commands/server/server_command.rb:42:in start' from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.1.5/lib/rails/commands/server/server_command.rb:135:in
block in perform'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.1.5/lib/rails/commands/server/server_command.rb:130:in tap' from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.1.5/lib/rails/commands/server/server_command.rb:130:in
perform'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/thor-0.20.0/lib/thor/command.rb:27:in run' from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in
invoke_command'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/thor-0.20.0/lib/thor.rb:387:in dispatch' from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.1.5/lib/rails/command/base.rb:63:in
perform'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.1.5/lib/rails/command.rb:44:in invoke' from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/railties-5.1.5/lib/rails/commands.rb:16:in
<top (required)>'
from bin/rails:4:in require' from bin/rails:4:in
<main>'
該当のソースコード
Ruby on rails
Rails.application.routes.draw do
root 'static_pages#home'
get '/help', to: 'static_pages#help'
get '/about', to: 'static_pages#about'
get '/contact', to: 'static_pages#contact'
get '/signup', to: 'users#new'
resources :users
end
試したこと
routes.rbに誤字あると思ったので
手入力していたものを、tutorialに記載されてるコードをコピーペーストしてみました。検索で同じようなエラーを調べたのですが、同名のエラーはありませんでした。
補足情報(FW/ツールのバージョンなど)
ruby 2.4.3p205 (2017-12-14 revision 61247) [x64-mingw32]
Rails 5.1.5
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/05/17 13:19