`
xf986321
  • 浏览: 160475 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

RAILS

阅读更多
1.1 创建Rails应用程序
$ rails [_VERSION_] app_name
可选项:
VERSION: 指定rails的版本(如果安装了多个rails版本),VERSION前后各加一下划线, 如"_1.2.6_"
-d, database=xxx 指定安装一个数据库(mysql oracle postgresql sqlite2 sqlite3 ), 默认情况下是数据库
-r, ruby-path= 指定Ruby的安装路径,如果没有指定,scripts使用env去找Ruby
-f, freeze (冻结)freezes Rails在vendor/rails目录

1.2 API Documentation
$ gem_server
启动一个WEBrick服务器。这时候你可以通过Http://localhost:8808/ 打开浏览器去查看rails API文档

1.3 Rake
rake db:fixtures:load
# 载入fixtures到当前环境的数据库
# 载入指定的fixtures使用FIXTURES=x,y
rake db:migrate
# 迁移数据库通过在db/migrate目录下的脚本.可以指定版本号通过VERSION=x
rake db:schema:dump
# 创建一个db/schema.rb文件,通过AR能过够支持任何数据库去使用
rake db:schema:load
# 再入一个schema.rb文件进数据库
rake db:sessions:clear
# 清空sessions表
rake db:sessions:create
# 用CGI::Session::ActiveRecordStore创建一个sessions表为用户
rake db:structure:dump
# 导出数据库结构为一个SQL文件
rake db:test:clone
# 重新创建一个测试数据库从当前环境数据库中
rake db:test:clone_structure
# 重新创建测试数据库从开发模式数据库
rake db:test:prepare
# 准备测试数据库并在入schema
rake db:test:purge
# 清空测试数据库
rake doc:app
# 创建HTML文件的API Documentation
rake doc:clobber_app
# 删除Documentation
rake doc:clobber_plugins
# 删除 plugin Documentation
rake doc:clobber_rails
# 删除Documentation
rake doc:plugins
# 产生Documation为所有安装的plugins
rake doc:rails
# 创建HTML文件的API Documentation
rake doc:reapp
# 强制重新创建HTML文件的API Documentation
rake doc:rerails
# 强制重新创建HTML文件的API Documentation
rake log:clear
# 清空目录log/下的所有日志文件
rake rails:freeze:edge
# Lock this application to latest Edge Rails. Lock a specific revision with REVISION=X
rake rails:freeze:gems
# Lock this application to the current gems (by unpacking them into vendor/rails)
rake rails:unfreeze
# Unlock this application from freeze of gems or edge and return to a fluid use of system gems
rake rails:update
# Update both scripts and public/javascripts from Rails
rake rails:update:javascripts
# Update your javascripts from your current rails install
rake rails:update:scripts
# Add new scripts to the application script/ directory
rake stats
# Report code statistics (KLOCs, etc) from the application
rake test
# Test all units and functionals
rake test:functionals
# Run tests for functionalsdb:test:prepare
rake test:integration
# Run tests for integrationdb:test:prepare
rake test:plugins
# Run tests for pluginsenvironment
rake test:recent
# Run tests for recentdb:test:prepare
rake test:uncommitted
# Run tests for uncommitteddb:test:prepare
rake test:units
# Run tests for unitsdb:test:prepare
rake tmp:cache:clear
# 清空tmp/cache目录下的所有文件
rake tmp:clear
# 清空session, cache, 和socket文件从tmp/目录
rake tmp:create
# 为sessions, cache, and sockets创建tmp/目录
rake tmp:sessions:clear
# 清空所有在tmp/sessions目录下的文件
rake tmp:sockets:clear
# 清空所有在tmp/sessions 目录下的ruby_sess.* 文件
 
rails 2.0新增的Rake Tasks
rake routes:打印当前路由列表;
rake db:drop, rake db:drop:all, 删除当前环境或config/database.yml中的所有数据库;
rake db:create, rake db:create:all,创建当前环境数据库或或config/database.yml中的所有数据库;
rake db:version,显示当前环境数据库的schema版本号;
rake db:reset, 删除并重新创建当前环境的数据库。


1.4 Scripts
script/about
# 输出当前环境信息
script/breakpointer
# 启动断点server
script/console
# 启动交换式的Rails控制台
script/destroy
# 删除通过generators创建的文件
script/generate
# -> generators
script/plugin
# -> Plugins
script/runner
# 执行一个任务在rails上下文中
script/server
# 启动开发模式服务器http://localhost:3000
//以下几个不知道怎么去使用
script/performance/profiler
script/performance/benchmarker
script/process/reaper
script/process/spawner

1.5 Generators
ruby script/generate model ModelName
ruby script/generate controller ListController show edit
ruby script/generate scaffold ModelName ControllerName
ruby script/generate migration AddNewTable
ruby script/generate plugin PluginName
ruby script/generate mailer Notification lost_password signup
ruby script/generate web_service ServiceName api_one api_two
ruby script/generate integration_test TestName
ruby script/generate session_migration
可选项:
-p, --pretend Run but do not make any changes.
-f, --force Overwrite files that already exist.
-s, --skip Skip files that already exist.
-q, --quiet Suppress normal output.
-t, --backtrace Debugging: show backtrace on errors.
-h, --help Show this help message.
-c, --svn Modify files with subversion. (Note: svn must be in path)

1.6 Plugins
script/plugin discover
# discover plugin repositories
script/plugin list
# list all available plugins
script/plugin install where
# install the a€wherea€? plugin
script/plugin install -x where
# install where plugin as SVN external
script/plugin install http://invisible.ch/projects/plugins/where
script/plugin update
# update installed plugins
script/plugin source
# add a source repository
script/plugin unsource
# removes a source repository
script/plugin sources
# lists source repositories

分享到:
评论
1 楼 GunChin 2012-05-03  
有些复杂,看得不是很懂

相关推荐

    [Rails] Crafting Rails Applications (英文版)

    [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, ...

    Rails.Angular.Postgres.and.Bootstrap.2nd.Edition

    With this fully revised new edition, take a holistic view of full-stack development to create usable, high-performing applications with Rails 5. Rails is a great tool for building web applications, ...

    Ruby on Rails Tutorial

    《Ruby on Rails Tutorial》中文版(原书第2版,涵盖 Rails 4) Ruby 是一门很美的计算机语言,其设计原则就是“让编程人员快乐”。David Heinemeier Hansson 就是看重了这一点,才在开发 Rails 框架时选择了 Ruby...

    Rails之道,完整扫描版

    《Rails之道》按照Rails的各个子系统进行组织编排,分别介绍了Rails的环境、初始过程、配置和日志记录,Rails的分配器、控制器、页面生成和路由,REST、资源和Rails,ActiveRecord的基础、关联、验证和高级技巧,...

    提升Ruby on Rails性能的几个解决方案

    Ruby On Rails 框架自它提出之日起就受到广泛关注,在“不要重复自己”,“约定优于配置”等思想的指导下,Rails 带给 Web 开发者的是极高的开发效率。 ActiveRecord 的灵活让你再也不用配置繁琐的 Hibernate 即可...

    Bootstrap for Rails (2015)

    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 ...

    Ruby on Rails Guides v2 - Ruby on Rails 4.2.5

    Ruby on Rails Guides v2 - Ruby on Rails 4.2.5

    Agile Web Development with Rails 4

    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 ...

    Learning Rails 5(高清文字pdf版)

    If you’re a web developer or designer ready to learn Ruby on Rails, this hands-on guide is the ideal way to get started. Rather than toss you into the middle of the framework’s Model-View-Controller...

    rails敏捷开发的购物车系统

    本资源是参照rails敏捷开发第四版书中的例子,rails的版本是rails3.2.6

    Rails项目源代码

    一个用Ruby on Rails搭建的图片分享的网站项目.完整源代码

    Ruby on rails tutorial中文版(第二版)

    我读过很多 Rails 相关的书,但是这本真正让我入门了。书里的一切都很符合“Rails 之道”,我以前觉得这个道很不自然,但是读完这本书,感觉却是自然无比。本书也是唯一一本自始至终都是用测试驱动开发理念的 Rails ...

    Rails Recipes英文版(清晰文字pdf+源码)

    Ruby三神书之一(其余的两本是Agile.Web.Development.with.Rails和Ruby For Rails,在我的资源列表也有) Rails is large, powerful, and new. How do you use it effectively? How do you harness the power? And, ...

    [Michael Hartl] Ruby on Rails Tutorial

    Learn Web Development with Rails Clear EPUB version in English, Second Edition “The author is clearly an expert at the Ruby language and the Rails framework, but more than that, he is a working ...

    深入浅出Rails(中文版)

    《深入浅出Rails(影印版)》内容简介:通过此书,你将学习:希望你的网络应用超越平庸进入Web 2.0时代?《深入浅出Rails》将使你的编程和生产力达到最大值。你将学习一切Rails scaffolding的基本原理,以创建自定义的...

    常用RAILS学习网站

    收集了常用RAILS学习的网址 收集了常用RAILS学习的网址

    rails 5 test prescriptions build a healthy codebase

    Your Ruby on Rails application is sick. Deadlines are looming, but every time you make the slightest change to the code, something else breaks. Nobody remembers what that tricky piece of code was ...

Global site tag (gtag.js) - Google Analytics