ユーティリティ--railsコマンド、generator

3704 ワード

1、rails   
rails new rails-bootstrap -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb

rails new User_Auth -d mysql

rails new $1 -m https://raw.github.com/RailsApps/rails-composer/master/composer.rb

rails g model comment content:text commentable_id:integer commentable_type
rake db:migrate
rails g controller comments index new

rails new myapp -D postgres
cd myapp
rails generate scaffold user name:string age:integer
rake db:create
rake db:migrate

Rails app with mongoid devise haml
rails new webdb -m http://railswizard.org/77171980b8637239194c.rb -J -O -T

$ rails generate controller Noticias titulo
$ rails destroy controller Noticias titulo
$ rails generate model Noticia titulo:string
$ rails destroy model Noticia
 
$ rake db:migrate
$ rake db:rollback
$ rake db:migrate VERSION=0 #defaz todas as migrations, deixa o banco "limpo" 
$ rake db:migrate:reset #reseta todo o banco, perdendo todos os registros, e já executa novamente as todas as migrations

2、devise setup
rails g devise:install
rails g devise User
rails g devise:views
rake db:migrate 
3、Command to start delayed_job in production
RAILS_ENV=production script/delayed_job start
4、active_admin

install active_admin
bundle install
rails generate active_admin:install
rake db:migrate
rails s

generate active_admin ressources
rails generate active_admin:resource user
rails generate active_admin:resource product
rails generate active_admin:resource order
5、# Vagrant
vagrant halt
vagrant package --output ubuntu-12.04-LTS-RVM-Rails
vagrant box list
vagrant box add ubuntu-12.04-LTS-RVM-Rails ubuntu-12.04-LTS-RVM-Rails
vagrant box list
6、rvm rails


$ gem update --system# Get latest RubyGem
$ gem update ruby# Get latest Ruby
$ gem update rails# Get latest Rails

rvm use [email protected] --create# Set up rvm to use a different gemset (which in this case we will call Rails3.2)
 

gem install rails -v 3.2# install Rails 3.2 in that gemset
 

rvm gemset list# list the available rvm gemsets


HOW TO CREATE A GEMSET
#  RVM   ,       Ruby 1.9.2-p180,  Ruby 1.9.2-p180   
rvm 1.9.2-p180 
#  Ruby 1.9.2-p180    ,    Ruby Rails    
rvm gemset create rails309 
#   1.9.2-p180@rails309    
rvm 1.9.2-p180@rails309 
#     Rails,      :
# "builder-2.1.2 has an invalid value for @cert_chain" 
#   gem
gem update --system 
#   gem   1.6.2
gem update --system 1.6.2 
#  1.9.2-p180@rails309     ,  Rails  3.0.9
gem install rails -v 3.0.9



7、git
git init
git add .
git ci -m "first commit"
8、vim
#   vim-rails
cd ~/.vim/bundle
git clone git://github.com/tpope/vim-rails.git
 
#   vim-rails  
git clone git://github.com/cnruby/learn_rails.git
cd learn_rails/gon_demo
vim
:Rcontroller products<   >
:Rtree<   >
#               3。


#   Vimmer
gem install vimmer
 
#   Vimmer  
vim install https://github.com/tpope/vim-rails