Skip to content

Instantly share code, notes, and snippets.

@davbre
Created January 28, 2012 07:51
Show Gist options
  • Save davbre/1693310 to your computer and use it in GitHub Desktop.
Save davbre/1693310 to your computer and use it in GitHub Desktop.
rails commands
rails generate model Modelname attr1:string attr2:integer
rails destroy model Modelname
rails generate migration add_user_id_to_posts user_id:integer
/* Delete and re-create */
rake db:drop
rake db:create
rake db:migrate
rake db:reset
rake db:migrate
rake db:test:prepare
rake db:populate (own task)
Object.methods.grep /string/
hirb (gem for viewing query results in console). See http://tagaholic.me/2009/03/13/hirb-irb-on-the-good-stuff.html
-----
require 'hirb'
Hirb::View.enable
Devise
------
rails generate devise:install
rails generate devise User
rake db:migrate
rails generate devise:views
Convert to HAML
---------------
gem install hpricot
gem install ruby_parser
for i in `find app/views/devise -name '*.erb'` ; do html2haml -e $i ${i%erb}haml ; done
Debug
-----
debug variable, e.g. debug(params)
simple_format session.to_yaml
myobj.inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment