Rails的文件结构(Directory structure of a Rails application)

本文介绍了使用NetBeans创建Ruby on Rails项目时的目录结构。详细解释了各目录的作用,如app目录下控制器、模型和视图文件的位置,以及配置、测试等文件夹的内容。
When you ask NetBeans to create a Rails project  - internally NetBeans uses the rails' helper script -, it creates the entire directory structure for your application. Rails knows where to find things it needs within this structure, so you don't have to tell it explicitly.

The directory structure of a Rails application looks as following.  Please note that NetBeans uses logical names to reflect these directories. For example, the Controllers node represents app/controllers directory while Models node represents app/models.  If you click Files view of the project, you will see the directories mentioned below.

app
Holds all the code that's specific to this particular application.
app/controllers
Holds controllers that should be named like hello_controller.rb for automated URL mapping. 
All controllers should descend from ApplicationController which itself descends from ActionController::Base.
app/models
Holds models that should be named like message.rb.
Most models will descend from ActiveRecord::Base.
app/views
Holds the template files for the view that should be named like hello/say_hello.rhtml for the HelloController#say_hello action. 
app/views/layouts
Holds the template files for layouts to be used with views. 
This models the common header/footer method of wrapping views. In your views, define a layout using the <tt>layout :default</tt> and create a file named default.rhtml. Inside default.rhtml, call <% yield %> to render the view using this layout.
app/helpers
Holds view helpers that should be named like hello_helper.rb. These are generated for you automatically when using script/generate for controllers. Helpers can be used to wrap functionality for your views into methods.
config
Configuration files for the Rails environment, the routing map, the database, and other dependencies.
components
Self-contained mini-applications that can bundle together controllers, models, and views.
db
Contains the database schema in schema.rb.  
db/migrate
Contains all the sequence of Migrations for your schema.
doc
This directory is where your application documentation will be stored when generated using <tt>rake doc:app</tt>
lib
Application specific libraries. Basically, any kind of custom code that doesn't belong under controllers, models, or helpers. This directory is in the load path.
public 
The directory available for the web server. 
Contains subdirectories for images, stylesheets, and javascripts. 
Also contains the dispatchers and the default HTML files. 
This should be set as the DOCUMENT_ROOT of your web server.
script
Helper scripts for automation and generation.
test
Unit and functional tests along with fixtures. When using the script/generate scripts, template test files will be generated for you and placed in this directory.
vendor 
External libraries that the application depends on. Also includes the plugins subdirectory.
This directory is in the load path.
Physical directories that are created for the Ruby on Rails project

Usage: rails new APP_PATH [options] Options: [--skip-namespace] # Skip namespace (affects only isolated engines) # Default: false [--skip-collision-check] # Skip collision check # Default: false -r, [--ruby=PATH] # Path to the Ruby binary of your choice # Default: C:/Ruby34-x64/bin/ruby.exe -n, [--name=NAME] # Name of the app -m, [--template=TEMPLATE] # Path to some application template (can be a filesystem path or URL) -d, [--database=DATABASE] # Preconfigure for selected database # Default: sqlite3 # Possible values: mysql, trilogy, postgresql, sqlite3, mariadb-mysql, mariadb-trilogy -G, [--skip-git] # Skip git init, .gitignore and .gitattributes [--skip-docker] # Skip Dockerfile, .dockerignore and bin/docker-entrypoint [--skip-keeps] # Skip source control .keep files -M, [--skip-action-mailer] # Skip Action Mailer files [--skip-action-mailbox] # Skip Action Mailbox gem [--skip-action-text] # Skip Action Text gem -O, [--skip-active-record] # Skip Active Record files [--skip-active-job] # Skip Active Job [--skip-active-storage] # Skip Active Storage files -C, [--skip-action-cable] # Skip Action Cable files -A, [--skip-asset-pipeline] # Skip the asset pipeline setup -J, --skip-js, [--skip-javascript] # Skip JavaScript files [--skip-hotwire] # Skip Hotwire integration [--skip-jbuilder] # Skip jbuilder gem -T, [--skip-test] # Skip test files [--skip-system-test] # Skip system test files [--skip-bootsnap] # Skip bootsnap gem [--skip-dev-gems] # Skip development gems (e.g., web-console) [--skip-thruster] # Skip Thruster setup [--skip-rubocop] # Skip RuboCop setup [--skip-brakeman] # Skip brakeman setup [--skip-bundler-audit] # Skip bundler-audit setup [--skip-ci] # Skip GitHub CI files [--skip-kamal] # Skip Kamal setup [--skip-solid] # Skip Solid Cache, Queue, and Cable setup [--dev], [--no-dev], [--skip-dev] # Set up the application with Gemfile pointing to your Rails checkout [--devcontainer], [--no-devcontainer], [--skip-devcontainer] # Generate devcontainer files [--edge], [--no-edge], [--skip-edge] # Set up the application with a Gemfile pointing to the 8-1-stable branch on the Rails repository --master, [--main], [--no-main], [--skip-main] # Set up the application with Gemfile pointing to Rails repository main branch [--rc=RC] # Path to file containing extra configuration options for rails command [--no-rc] # Skip loading of extra configuration options from .railsrc file [--api], [--no-api], [--skip-api] # Preconfigure smaller stack for API only apps # Default: false [--minimal], [--no-minimal], [--skip-minimal] # Preconfigure a minimal rails app -j, --js, [--javascript=JAVASCRIPT] # Choose JavaScript approach # Default: importmap # Possible values: importmap, bun, webpack, esbuild, rollup -c, [--css=CSS] # Choose CSS processor. Check https://github.com/rails/cssbundling-rails for more options # Possible values: tailwind, bootstrap, bulma, postcss, sass -B, [--skip-bundle] # Don't run bundle install [--skip-decrypted-diffs] # Don't configure git to show decrypted diffs of encrypted credentials Runtime options: -f, [--force] # Overwrite files that already exist -p, [--pretend], [--no-pretend], [--skip-pretend] # Run but do not make any changes -q, [--quiet], [--no-quiet], [--skip-quiet] # Suppress status output -s, [--skip], [--no-skip], [--skip-skip] # Skip files that already exist Rails options: -h, [--help], [--no-help], [--skip-help] # Show this help message and quit -v, [--version], [--no-version], [--skip-version] # Show Rails version number and quit Description: The `rails new` command creates a new Rails application with a default directory structure and configuration at the path you specify. You can specify extra command-line arguments to be used every time `rails new` runs in the .railsrc configuration file in your home directory, or in $XDG_CONFIG_HOME/rails/railsrc if XDG_CONFIG_HOME is set. Note that the arguments specified in the .railsrc file don't affect the default values shown above in this help message. You can specify which version to use when creating a new rails application using `rails _<version>_ new`. Examples: `rails new ~/Code/Ruby/weblog` This generates a new Rails app in ~/Code/Ruby/weblog. `rails _<version>_ new weblog` This generates a new Rails app with the provided version in ./weblog. `rails new weblog --api` This generates a new Rails app in API mode in ./weblog. `rails new weblog --skip-action-mailer` This generates a new Rails app without Action Mailer in ./weblog. Any part of Rails can be skipped during app generation.
11-13
PS E:\rubyProject\student_curd> bundle exec rails server Usage: rails new APP_PATH [options] Options: [--skip-namespace], [--no-skip-namespace] # Skip namespace (affects only isolated engines) [--skip-collision-check], [--no-skip-collision-check] # Skip collision check -r, [--ruby=PATH] # Path to the Ruby binary of your choice # Default: E:/Bitnami/redmine-5.0.3-0/ruby/bin/ruby.exe -m, [--template=TEMPLATE] # Path to some application template (can be a filesystem path or URL) -d, [--database=DATABASE] # Preconfigure for selected database (options: mysql/postgresql/sqlite3/oracle/sqlserver/jdbcmysql/jdbcsqlite3/jdbcpostgresql/jdbc) # Default: sqlite3 [--skip-gemfile], [--no-skip-gemfile] # Don't create a Gemfile -G, [--skip-git], [--no-skip-git] # Skip .gitignore file [--skip-keeps], [--no-skip-keeps] # Skip source control .keep files -M, [--skip-action-mailer], [--no-skip-action-mailer] # Skip Action Mailer files [--skip-action-mailbox], [--no-skip-action-mailbox] # Skip Action Mailbox gem [--skip-action-text], [--no-skip-action-text] # Skip Action Text gem -O, [--skip-active-record], [--no-skip-active-record] # Skip Active Record files [--skip-active-job], [--no-skip-active-job] # Skip Active Job [--skip-active-storage], [--no-skip-active-storage] # Skip Active Storage files -P, [--skip-puma], [--no-skip-puma] # Skip Puma related files -C, [--skip-action-cable], [--no-skip-action-cable] # Skip Action Cable files -S, [--skip-sprockets], [--no-skip-sprockets] # Skip Sprockets files [--skip-spring], [--no-skip-spring] # Don't install Spring application preloader [--skip-listen], [--no-skip-listen] # Don't generate configuration that depends on the listen gem -J, [--skip-javascript], [--no-skip-javascript] # Skip JavaScript files [--skip-turbolinks], [--no-skip-turbolinks] # Skip turbolinks gem [--skip-jbuilder], [--no-skip-jbuilder] # Skip jbuilder gem -T, [--skip-test], [--no-skip-test] # Skip test files [--skip-system-test], [--no-skip-system-test] # Skip system test files [--skip-bootsnap], [--no-skip-bootsnap] # Skip bootsnap gem [--dev], [--no-dev] # Set up the application with Gemfile pointing to your Rails checkout [--edge], [--no-edge] # Set up the application with Gemfile pointing to Rails repository [--master], [--no-master] # Set up the application with Gemfile pointing to Rails repository main branch [--rc=RC] # Path to file containing extra configuration options for rails command [--no-rc], [--no-no-rc] # Skip loading of extra configuration options from .railsrc file [--api], [--no-api] # Preconfigure smaller stack for API only apps [--minimal], [--no-minimal] # Preconfigure a minimal rails app -B, [--skip-bundle], [--no-skip-bundle] # Don't run bundle install --webpacker, [--webpack=WEBPACK] # Preconfigure Webpack with a particular framework (options: react, vue, angular, elm, stimulus) [--skip-webpack-install], [--no-skip-webpack-install] # Don't run Webpack install Runtime options: -f, [--force] # Overwrite files that already exist -p, [--pretend], [--no-pretend] # Run but do not make any changes -q, [--quiet], [--no-quiet] # Suppress status output -s, [--skip], [--no-skip] # Skip files that already exist Rails options: -h, [--help], [--no-help] # Show this help message and quit -v, [--version], [--no-version] # Show Rails version number and quit Description: The 'rails new' command creates a new Rails application with a default directory structure and configuration at the path you specify. You can specify extra command-line arguments to be used every time 'rails new' runs in the .railsrc configuration file in your home directory, or in $XDG_CONFIG_HOME/rails/railsrc if XDG_CONFIG_HOME is set. Note that the arguments specified in the .railsrc file don't affect the defaults values shown above in this help message. Example: rails new ~/Code/Ruby/weblog This generates a skeletal Rails installation in ~/Code/Ruby/weblog.
09-09
【轴承故障诊断】加权多尺度字典学习模型(WMSDL)及其在轴承故障诊断上的应用(Matlab代码实现)内容概要:本文介绍了加权多尺度字典学习模型(WMSDL)在轴承故障诊断中的应用,并提供了基于Matlab的代码实现。该模型结合多尺度分析与字典学习技术,能够有效提取轴承振动信号中的故障特征,提升故障识别精度。文档重点阐述了WMSDL模型的理论基础、算法流程及其在实际故障诊断中的实施步骤,展示了其相较于传统方法在特征表达能力和诊断准确性方面的优势。同时,文中还提及该资源属于一个涵盖多个科研方向的技术合集,包括智能优化算法、机器学习、信号处理、电力系统等多个领域的Matlab仿真案例。; 适合人群:具备一定信号处理和机器学习基础,从事机械故障诊断、工业自动化、智能制造等相关领域的研究生、科研人员及工程技术人员。; 使用场景及目标:①学习并掌握加权多尺度字典学习模型的基本原理与实现方法;②将其应用于旋转机械的轴承故障特征提取与智能诊断;③结合实际工程数据复现算法,提升故障诊断系统的准确性和鲁棒性。; 阅读建议:建议读者结合提供的Matlab代码进行实践操作,重点关注字典学习的训练过程与多尺度分解的实现细节,同时可参考文中提到的其他相关技术(如VMD、CNN、BILSTM等)进行对比实验与算法优化。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值