Skip to content

Instantly share code, notes, and snippets.

@seanwalsh
Last active November 10, 2016 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seanwalsh/9349cae5870df18aeab7bd651339fddf to your computer and use it in GitHub Desktop.
Save seanwalsh/9349cae5870df18aeab7bd651339fddf to your computer and use it in GitHub Desktop.
Notes for Ruby on Rails

Rails Commands

rails g migration RemoveFieldFromTable field:type
rails g migration RenameBreedToBreedNameInCats

Rake Commands

rake db:setup
rake db:migrate
rake db:seed
rake db:drop

rake routes

Heroku Commands

heroku create

heroku run rake db:migrate
heroku run rake db:seed

heroku maintenance:on
heroku maintenance:off

Git Commands

heroku git:remote -a project
git remote set-url heroku <new-url>
git remote rm heroku

git push heroku master
git push --force heroku master
git remote -v

GEMs

Canonical URLs

http://blog.planetargon.com/entries/easily-add-canonical-urls-to-your-rails-app

HAML Conversion

rake haml:erb2haml

GTM

https://github.com/rcs/google-tag-manager-rails

Add to the Gemfile gem 'google-tag-manager-rails'

Then run:

bundle install

In config/environments/production.rb : add

GoogleTagManager.gtm_id = "GTM-XXXX" # Where GTM-XXXX is your container ID from Google Tag Manager

In app/views/layouts/application.html.erb: add

%body
  = google_tag_manager
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment