rails generate controller StaticPages home help --no-test-framework 使用 --no-test-framework 选项禁用rspec框架生成测试代码。另外Rails会调用underscore方法把驼峰式的命名修改成蛇底式。例如上面的StatiPages的控制器对应的文件名为:static_pages_controller.rb,这只是一个约定,在命令行中也可使用蛇底式。css
在生成错误的时候可使用 rails destroy [controller|model|view] [controller_name] [action] [action...]
来删除指定的controllerhtml
rake 用来编译构建项目的一个工具,相似于unix下的make命令,能够用 rake -T 命令来查看有什么操做指令。mysql
也能够查看指定的命令的帮助,例如:rake -T dbjquery
rake about # List versions of all Rails frameworks and the...
rake assets:clean # Remove old compiled assets
rake assets:clobber # Remove compiled assets
rake assets:environment # Load asset compile environment
rake assets:precompile # Compile all the assets named in config.assets...
rake db:create # Create the database from DATABASE_URL or conf...
rake db:drop # Drops the database using DATABASE_URL or the ...
rake db:fixtures:load # Load fixtures into the current environment's ...
rake db:migrate # Migrate the database (options: VERSION=x, VER...
rake db:migrate:status # Display status of migrations
rake db:rollback # Rolls the schema back to the previous version...
rake db:schema:cache:clear # Clear a db/schema_cache.dump file
rake db:schema:cache:dump # Create a db/schema_cache.dump file
rake db:schema:dump # Create a db/schema.rb file that can be portab...
rake db:schema:load # Load a schema.rb file into the database
rake db:seed # Load the seed data from db/seeds.rb
rake db:setup # Create the database, load the schema, and ini...
rake db:structure:dump # Dump the database structure to db/structure.sql
rake db:version # Retrieves the current schema version number
rake doc:app # Generate docs for the app -- also available d...
rake log:clear # Truncates all *.log files in log/ to zero byt...
rake middleware # Prints out your Rack middleware stack
rake notes # Enumerate all annotations (use notes:optimize...
rake notes:custom # Enumerate a custom annotation, specify with A...
rake rails:template # Applies the template supplied by LOCATION=(/p...
rake rails:update # Update configs and some other initially gener...
rake routes # Print out all defined routes in match order, ...
rake secret # Generate a cryptographically secure secret ke...
rake stats # Report code statistics (KLOCs, etc) from the ...
rake test # Runs test:units, test:functionals, test:integ...
rake test:all # Run tests quickly by merging all types and no...
rake test:all:db # Run tests quickly, but also reset db
rake test:recent # Run tests for {:recent=>["test:deprecated", "...
rake test:uncommitted # Run tests for {:uncommitted=>["test:deprecate...
rake time:zones:all # Displays all time zones, also available: time...
rake tmp:clear # Clear session, cache, and socket files from t...
rake tmp:create # Creates tmp directories for sessions, cache, ...git
rails generate|g 生成器,能够以不一样的指令生成不一样形式的模板。github
Rails:sql
Coffee:数据库
Jquery:服务器
Js:restful
TestUnit:
bundle install:咱们使用 -without production 禁止安装生产环境所需的 gem。这个选项会被记住,因此后续调用 Bundler 就不用再指定这个选项,直接运行 bundle install 就能够自动不安装生产环境所需的 gem
加入gem
gem 'ckeditor'
gem 'paperclip'
生成文件rails generate ckeditor:install --orm=active_record --backend=paperclip
配置 model 环境,打开 application.rb 加入下面config.autoload_paths += %W(#{config.root}/app/models/ckeditor)
在 routes 里面增长 路由mount Ckeditor::Engine => "/ckeditor"
打开application.js 加入//= require ckeditor/init
更多内容请查看:https://github.com/galetahub/ckeditor
默认状况下Rails erb输出会转义html标签,如何在rails中不让html标签转义?
答:使用raw 或者 html_safe
如何过滤掉html、css、js标签?
答案:能够是用SanitizeHelper,有以下方法:sanitize、strip_css、strip_links、strip_tags
经常使用 rake 命令
rake assets:precompile 编译静态资源文件
rake routes 列出全部的restful route
rake stats 查看当前工程状况
rake secret 生成session 加密指纹
Rails debug
增长下面的代码gem debugger
rails s --debugger
而后在须要debug的地方加上 debugger 就能够了。
查看资源路径Rails.application.config.assets.paths
清除老版本的gem
gem cleanup
删除全部的已安装的gemfor i in ‘gem list --no-versions’; do gem uninstall -aIx $i; done
brew install libxml2 libxslt brew link libxml2 libxslt
sudo apt-get install mysql-server
mysqladmin -u帐号 -p老密码 password 新密码
create database ``test`` default character set utf8;
http://dhq.me/mac-postgresql-install-usage
删除数据库
heroku pg:reset
第一章 http://www.tuicool.com/articles/3uyAny
第二章 http://www.tuicool.com/articles/Y363Erf
第三章 http://www.tuicool.com/articles/MnMf2i
第四章 http://www.tuicool.com/articles/j2Erye
第五章 http://www.tuicool.com/articles/u6FRBr7
第六章 http://www.tuicool.com/articles/6j67je