首页 > 学院 > 开发设计 > 正文

Ruby on Rails所构建的应用程序基本目录结构总结

2019-10-26 19:29:06
字体:
来源:转载
供稿:网友

当使用rails new appname生成Rails应用后,我们可以通过tree来查看Rails应用的目录结构:

目录结构

应用程序目录下会有app、config、db、doc、lib、log、public、script、test、tmp和vendor等11个目录和config.ru、Gemfile、Gemfile.lock、Rakefile、README.rdoc等5个文件。

目录在稍后会一一解释,先看一下app目录下的文件:

config.ru 用来启动Rails程序的Rack设置文件

require ::File.expand_path('../config/environment', __FILE__)run Myapps::Application

Gemfile设置Rails程序所依赖的Gems (一旦用bundle install安装后,会生成Gemfile.lock)

source 'https://ruby.taobao.org/'gem 'rails', '3.2.1'gem 'sqlite3'# Gems used only for assets and not required# in production environments by default.group :assets do gem 'sass-rails',  '~> 3.2.3' gem 'coffee-rails', '~> 3.2.1' gem 'uglifier', '>= 1.0.3'endgem 'jquery-rails'gem ... ...

Rakefile 用来载入可以被终端执行的Rake任务
<!--more-->

下面是用tree命令查看,所显示的目录和文件结构:

.├── app│  ├── assets│  │  ├── images│  │  │  └── rails.png│  │  ├── javascripts│  │  │  └── application.js│  │  └── stylesheets│  │    └── application.css│  ├── controllers│  │  └── application_controller.rb│  ├── helpers│  │  └── application_helper.rb│  ├── mailers│  ├── models│  └── views│    └── layouts│      └── application.html.erb├── config│  ├── application.rb│  ├── boot.rb│  ├── database.yml│  ├── environment.rb│  ├── environments│  │  ├── development.rb│  │  ├── production.rb│  │  └── test.rb│  ├── initializers│  │  ├── backtrace_silencers.rb│  │  ├── inflections.rb│  │  ├── mime_types.rb│  │  ├── secret_token.rb│  │  ├── session_store.rb│  │  └── wrap_parameters.rb│  ├── locales│  │  └── en.yml│  └── routes.rb├── config.ru├── db│  └── seeds.rb├── doc│  └── README_FOR_APP├── Gemfile├── lib│  ├── assets│  └── tasks├── log├── public│  ├── 404.html│  ├── 422.html│  ├── 500.html│  ├── favicon.ico│  ├── index.html│  └── robots.txt├── Rakefile├── README.rdoc├── script│  └── rails├── test│  ├── fixtures│  ├── functional│  ├── integration│  ├── performance│  │  └── browsing_test.rb│  ├── test_helper.rb│  └── unit├── tmp│  └── cache│    └── assets└── vendor  ├── assets  │  ├── javascripts  │  └── stylesheets  └── plugins            
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表