- 浏览: 131340 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (140)
- ruby on rails (23)
- 随笔 (1)
- 部署 (3)
- ubuntu源 (2)
- linux (28)
- web (9)
- IT (3)
- linux,数据库 (3)
- MOOC (4)
- ubuntu (20)
- win7 (2)
- git (6)
- github (2)
- ubuntu,python (1)
- java,JDK (1)
- ubuntu,qq (1)
- vagrant (3)
- virtualbox (2)
- sass (1)
- centos (3)
- Sublime (1)
- nginx (4)
- passenger (1)
- VPN (0)
- mysql (4)
- VIM (1)
- bbb (1)
- 编码设置 (2)
- mongo (4)
- edx (2)
- ssh (1)
- python (1)
- phpmyadmin (1)
- libreoffice (2)
- docker (4)
- pg (1)
- PostgreSQL (2)
- 系统时间设置 (1)
- ansible (1)
- Sinatra (1)
- 硬盘挂载 (1)
- npm (1)
- smtp (1)
- docker 镜像 (1)
- Memcached (1)
最新评论
http://blog.58share.com/?cat=7
详解rails命令行
1.rails 命令
(1). rails new 创建项目
1
# 会生成一个基于数据库类型为sqlite3的项目
2
$ rails new demo
3
create README.rdoc
4
create Rakefile
5
create config.ru
6
create .gitignore
7
create Gemfile
8
.....
9
10
# 会生成一个基于mysql的项目
11
$ rails new demo -d=mysql
12
13
# 具体的每个参数的意思请参考
14
$ rails new --help
15
16
# 常用配置
17
$ rails new demo -d=mysql -TfJ # 跳过javascript,test
(2). rails server 启动项目
1
#rails s (rails server 简写)
2
$ rails s # development模式启动
3
$ rails s -e production # production模式启动
4
$ rails s -p 3001 # 以3001端口启动服务器
5
$ rails s -u # debugger调试使用
6
$ rails s -P=tmp/pids/server.pid # 以pid模式启动
7
8
$ rails s --help
(3). rails generate
1
# 用法: rails generate GENERATOR [args] [options]
2
$ rails g controller Demos index --no-test-framework # 创建一个控制器
3
$ rails g model demo # 创建一个model
4
$ rails g scaffold HighScore game:string score:integer # 创建一个脚手架
5
$ rails g migration add_column_to_table
6
7
$ rails g --help
(4). rails console
1
$ rails c # development模式
2
3
# 使用会回滚数据, 加了参数--sandbox后
4
$ rails console --sandbox
5
6
$ rails c production # production模式
(5). rails console / rails db 进入数据库
(6). rails runner / rails r
1
$ rails r 'Model.long_running_method' # 执行程序
2
$ rails r 'Model.long_running_method' -e production # production 模式
(7). rails destroy / rails d 清除数据
1
$ rails g model user # 创建model
2
$ rails d model user # 删除model
2. rake 命令
1
$ rake -T # 查看所有的rake命令
查看源代码打印帮助
1
$ rake about # 查看项目相关信息
2
$ rake assets:precompile # 编译压缩css,js,png图片, 放到public/assets目录下
3
$ rake assets:clean # 清除编译的文件
4
5
$ rake middleware # 查看rack #####
6
$ rake db:create # 创建数据库
7
$ rake db:drop # 删除数据库
8
$ rake db:migrate # 数据迁移 rake db:migrate RAILS_ENV=production
9
$ rake db:rollback # 回滚数据迁移
10
$ rake db:migrate:down VERSION=xxxxx # 回滚指定的迁移号
11
12
$ rake routes # 查看路由
13
14
$ rake tmp:cache:clear # clears tmp/cache.
15
$ rake tmp:sessions:clear # clears tmp/sessions.
16
$ rake tmp:sockets:clear # clears tmp/sockets.
17
$ rake tmp:clear # clears all the three: cache, sessions and sockets.
18
19
$ rake db:version # 查看当前数据迁移的版本
20
$ rake db:seed # 载入数据从 db/seeds.rb中
21
22
$ rake log:clear # 清空日志 log/*.log
详解rails命令行
1.rails 命令
(1). rails new 创建项目
1
# 会生成一个基于数据库类型为sqlite3的项目
2
$ rails new demo
3
create README.rdoc
4
create Rakefile
5
create config.ru
6
create .gitignore
7
create Gemfile
8
.....
9
10
# 会生成一个基于mysql的项目
11
$ rails new demo -d=mysql
12
13
# 具体的每个参数的意思请参考
14
$ rails new --help
15
16
# 常用配置
17
$ rails new demo -d=mysql -TfJ # 跳过javascript,test
(2). rails server 启动项目
1
#rails s (rails server 简写)
2
$ rails s # development模式启动
3
$ rails s -e production # production模式启动
4
$ rails s -p 3001 # 以3001端口启动服务器
5
$ rails s -u # debugger调试使用
6
$ rails s -P=tmp/pids/server.pid # 以pid模式启动
7
8
$ rails s --help
(3). rails generate
1
# 用法: rails generate GENERATOR [args] [options]
2
$ rails g controller Demos index --no-test-framework # 创建一个控制器
3
$ rails g model demo # 创建一个model
4
$ rails g scaffold HighScore game:string score:integer # 创建一个脚手架
5
$ rails g migration add_column_to_table
6
7
$ rails g --help
(4). rails console
1
$ rails c # development模式
2
3
# 使用会回滚数据, 加了参数--sandbox后
4
$ rails console --sandbox
5
6
$ rails c production # production模式
(5). rails console / rails db 进入数据库
(6). rails runner / rails r
1
$ rails r 'Model.long_running_method' # 执行程序
2
$ rails r 'Model.long_running_method' -e production # production 模式
(7). rails destroy / rails d 清除数据
1
$ rails g model user # 创建model
2
$ rails d model user # 删除model
2. rake 命令
1
$ rake -T # 查看所有的rake命令
查看源代码打印帮助
1
$ rake about # 查看项目相关信息
2
$ rake assets:precompile # 编译压缩css,js,png图片, 放到public/assets目录下
3
$ rake assets:clean # 清除编译的文件
4
5
$ rake middleware # 查看rack #####
6
$ rake db:create # 创建数据库
7
$ rake db:drop # 删除数据库
8
$ rake db:migrate # 数据迁移 rake db:migrate RAILS_ENV=production
9
$ rake db:rollback # 回滚数据迁移
10
$ rake db:migrate:down VERSION=xxxxx # 回滚指定的迁移号
11
12
$ rake routes # 查看路由
13
14
$ rake tmp:cache:clear # clears tmp/cache.
15
$ rake tmp:sessions:clear # clears tmp/sessions.
16
$ rake tmp:sockets:clear # clears tmp/sockets.
17
$ rake tmp:clear # clears all the three: cache, sessions and sockets.
18
19
$ rake db:version # 查看当前数据迁移的版本
20
$ rake db:seed # 载入数据从 db/seeds.rb中
21
22
$ rake log:clear # 清空日志 log/*.log
发表评论
-
ruby 回复功能
2015-03-24 21:44 590http://www.sitepoint.com/realti ... -
测试驱动开发(TDD)
2015-03-02 17:00 588测试驱动开发的基本过程如下: 1) 明确当前要完成的功能。可 ... -
Ruby is Big in China
2014-08-12 15:35 515http://stylesror.github.io/#rub ... -
ruby http get post
2014-07-31 11:22 722uri = URI('url') Net::H ... -
使用者認證
2014-07-29 11:18 398转自: http://ihower.tw/rails3/aut ... -
bundle exec rake i18n:check
2014-07-03 11:45 490bundle exec rake i18n:check -
ruby on rails+nginx+passenger+ubuntu
2014-06-06 00:19 822ruby 使用rvm安装 在使用rmv安装的ruby时候必 ... -
用 Ruby on Rails 实现适应各种平台的在线 Office 文档预览
2014-05-28 09:20 923前言 在许多Web应用中 ... -
`gem install nokogiri -v '1.5.6' 报错
2014-05-18 13:07 569libxml2 is missing. please vis ... -
卸载指定版本 bundle
2014-05-05 18:04 2639gem uninstall bundler -v=1.6.2 ... -
使用Vagrant在Windows下部署开发环境
2014-03-06 10:34 662http://blog.smdcn.net/article/1 ... -
安装rails时的一个小注意
2013-12-17 10:08 823在ubuntu上安装ROR环境时候,我总是忘记一件事情,就是设 ... -
GitHub使用指南!(ubuntu)
2013-12-06 00:03 1031<!-- @page { margin: 2cm } P ... -
关于在win7上安装Ruby On Rails 环境的几点注意
2013-12-05 18:31 1431在window下安装Ruby On Rails 环境须知: 1 ... -
Ubuntu安装Ruby On Rails多版本
2013-11-29 23:44 833写Ruby程序的时候,可能 ... -
ruby数组基本操作
2013-11-08 14:52 681#创建数组的几种方法#字面量创建的方法 a = [1,2,3 ... -
Rails2.2新特性:本地化与国际化(2008-12-15 14:21:41)
2013-11-01 11:05 802http://fsjoy.blog.51cto.com/318 ... -
浅析Ruby on Rails部署方案
2013-09-27 15:16 721http://blog.csdn.net/jrckkyy/ar ... -
【转载】我是如何让Ruby项目速度提升10倍的?
2013-09-06 13:18 627作者详细描述了他是如 ... -
How to install Ruby on Rails in Ubuntu 12.04 LTS
2013-08-27 11:10 600http://blog.sudobits.com/2012/0 ...
相关推荐
kemalyst-generator:Kemalyst之类的Rails命令行
新增类 代码如下:ruby script/generate Model <类名> <字段1>:<类型>… ruby script/generate Model Item name:string age:integer 移除类 代码如下:ruby script/destroy Model 新增控制器 ...
rails常用命令,例如新建rails项目,新建controller、model 等等
OpsWorks Rails 命令行手册 本说明书适用于在 Amazon Web Services OpsWorks 堆栈上使用 Ruby on Rails 的人员。 如果您在应用程序代码中引用通过应用程序配置屏幕设置的环境变量,那么您会发现在登录到实例时从...
rails 2.3.2离线安装rails 2.3.2离线安装rails 2.3.2离线安装rails 2.3.2离线安装rails 2.3.2离线安装rails 2.3.2离线安装rails 2.3.2离线安装rails 2.3.2离线安装rails 2.3.2离线安装rails 2.3.2离线安装rails ...
rails_apps_composer, 一个 gem,为 Rails 启动应用程序创建 Rails 应用程序模板 Rails 应用编辑器 Rails 应用程序编辑器 gem 安装一个 命令行 工具来从"食谱"的Collection 组装 Rails 应用程序。"你可以使用 rails_...
[Pragmatic Bookshelf] Crafting Rails Applications Expert Practices for Everyday Rails Development (E-Book) ☆ 图书概要:☆ Rails 3 is a huge step forward. You can now easily extend the framework, ...
Ruby on Rails Guides v2 - Ruby on Rails 4.2.5
《Ruby on Rails Tutorial》中文版(原书第2版,涵盖 Rails 4) Ruby 是一门很美的计算机语言,其设计原则就是“让编程人员快乐”。David Heinemeier Hansson 就是看重了这一点,才在开发 Rails 框架时选择了 Ruby...
《Rails之道》按照Rails的各个子系统进行组织编排,分别介绍了Rails的环境、初始过程、配置和日志记录,Rails的分配器、控制器、页面生成和路由,REST、资源和Rails,ActiveRecord的基础、关联、验证和高级技巧,...
本资源是参照rails敏捷开发第四版书中的例子,rails的版本是rails3.2.6
一个用Ruby on Rails搭建的图片分享的网站项目.完整源代码
Bootstrap 3 和 Rails 4(样例用的是Ruby 2.1.1,Rails 4.1.4) Table of Contents Preface 1 Chapter 1: Introducing Web Application Development in Rails 7 Why Bootstrap with Rails? 8 Setting up a Todo ...
adminlte-rails, AdminLTE Rails gem 将AdminLTE主题与 Rails 资产管道集成 AdminLTE Rails gem AdminLTE 是后端的高级 Bootstrap 主题。英镑 AdminLTE Rails gem 与 Rails 资产管道集成了英镑AdminLTE主题。安装将...
Ruby on Rails helps you produce high-quality, beautiful-looking web applications quickly. You concentrate on creating the application, and Rails takes care of the details., Tens of thousands of ...
Ruby On Rails 框架自它提出之日起就受到广泛关注,在“不要重复自己”,“约定优于配置”等思想的指导下,Rails 带给 Web 开发者的是极高的开发效率。 ActiveRecord 的灵活让你再也不用配置繁琐的 Hibernate 即可...
ruby on rails web开发详解的电子版,要用UnicornViewer打开才行。
征服RUBY ON RAILS WEB开发技术详解电子版,与part1一同解压