質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Q&A

解決済

1回答

5426閲覧

rails server の起動時にエラーがでて起動できません。

MasatoNagao

総合スコア7

Ruby on Rails 5

Ruby on Rails 5は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

0グッド

0クリップ

投稿2018/05/15 07:12

前提・実現したいこと

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

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

undefined local variable or method `xxx' for main:Object

xxxに入る文字が大事ですが
質問文を見る限り空白のようです。

カンですが全角空白が混じっているのでしょう

投稿2018/05/17 07:33

asm

総合スコア15147

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

MasatoNagao

2018/05/17 13:19

ありがとうございます。無事先に進めることができました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問