简体   繁体   English

如何使用Sublime Text在ROR中的应用程序根目录中创建文件example_user.rb

[英]How to create a file example_user.rb in your application root directory in ROR using Sublime Text

I am currently following Michael Hartl's Rails tutorial and not quite sure where to create the new example_user.rb file ( referenceed in section 4.4.5 ) because I am not sure what is meant by the root directory. 我目前正在关注Michael Hartl的Rails教程,但不确定在哪里创建新的example_user.rb文件( 在第4.4.5节中引用 ),因为我不确定根目录的含义。

I understand how to create a new file using Sublime Text but I am not sure what path to place it in. My educated guess would be to place it in: project_app/config/locales since it is an .rb file. 我知道如何使用Sublime Text创建新文件,但不确定将其放置在什么路径。我有根据的猜测是将其放置在:project_app / config / locales中,因为它是.rb文件。

Any suggestions under what path I should place this code? 我应该在什么路径下放置此代码任何建议?
Also, how could you accomplish this task using the command line? 另外,如何使用命令行完成此任务?

Many thanks! 非常感谢!

The tutorial says to create a example_user.rb file in your application root directory which would just be project_app/example_user.rb (based on your educated guess). 本教程说,要在应用程序的根目录中创建example_user.rb文件,该文件仅为project_app/example_user.rb (根据您的推测)。

project_app/config/locales/ wouldn't be appropriate; project_app/config/locales/不合适; that folder is used for something else entirely: http://guides.rubyonrails.org/i18n.html 该文件夹完全用于其他用途: http : //guides.rubyonrails.org/i18n.html

Zahid's comment about putting it in app/models/ is sort of correct but doesn't actually follow the tutorial. Zahid关于将其放在app/models/的评论是正确的,但实际上并没有遵循本教程。 As you get further into the tutorial, you'll learn that this example_user.rb file will later be moved from project_app/example_user.rb to project_app/app/models/user.rb after you have a better understanding of what Rails' models are. 当您进一步学习本教程时,您将了解到,在对Rails的模型有了更好的了解之后,该example_user.rb文件将稍后从project_app/example_user.rb移动到project_app/app/models/user.rb

Good luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM