Ruby on rails &引用;需要'/示例用户'&引用;结果是;LoadError:没有要加载的文件--./示例“U用户”;
我正在学习哈特尔的教程。 说明中说“在应用程序根目录中创建文件Ruby on rails &引用;需要'/示例用户'&引用;结果是;LoadError:没有要加载的文件--./示例“U用户”;,ruby-on-rails,ruby,Ruby On Rails,Ruby,我正在学习哈特尔的教程。 说明中说“在应用程序根目录中创建文件example\u user.rb”。我假设它就在rails\u projects/sample\u app下面。然后启动控制台并键入 require './example_user' 但是得到错误消息 `LoadError: no such file to load -- ./example_user`. 另一个答案是,您必须使用mv函数将文件移动到实际的根目录,但我无法理解这一点。根目录不只是在sample\u app中吗
example\u user.rb
”。我假设它就在rails\u projects/sample\u app
下面。然后启动控制台并键入
require './example_user'
但是得到错误消息
`LoadError: no such file to load -- ./example_user`.
另一个答案是,您必须使用mv函数将文件移动到实际的根目录,但我无法理解这一点。根目录不只是在sample\u app
中吗
谢谢你的帮助 在你的控制台中:试试看Dir.pwd,它会打印什么?上面写着“/Users/marlon/rails\u projects/sample\u app”,上面写着“[“app”,“config”,“config”,“config.ru”,“db”,“doc”,“Gemfile”,“Gemfile”,“Gemfile.lock”,“Guardfile”,“lib”,“log”,“public”,“Rakefile”,“README.md”,“script”,“spec”,“test”,“tmp”,“vendor”]。”您需要移动文件。我猜您是在其他地方意外创建了文件“example_user.rb”…请确保文件/Users/marlon/rails_projects/sample_app/example_user.rb存在并且是您正在编辑的文件。。。