Skip to content

Instantly share code, notes, and snippets.

@devonzuegel
Created March 26, 2015 09:24
Show Gist options
  • Save devonzuegel/113d18e4fa30b658dc9a to your computer and use it in GitHub Desktop.
Save devonzuegel/113d18e4fa30b658dc9a to your computer and use it in GitHub Desktop.
A collection of shortcuts and concepts I've learned the hard way and don't want to forget

Useful things to know about Rails

Command line utilities

Viewing your models:

$ rails console		// open up the Rails console

2.1.5 (main):0 > show-models		// show all models
Account
  id: integer
  created_at: datetime
  updated_at: datetime
  belongs_to :user
Micropost
  id: integer
  ...

2.1.5 (main):0 > show-model User	// show just the User model
User
  id: integer
  name: string
  email: string
  ...

Viewing your routes:

2.1.5 (main):0 > show-routes --grep charges
                charges GET    /charges(.:format)                      charges#index
                        POST   /charges(.:format)                      charges#create
             new_charge GET    /charges/new(.:format)                  charges#new
            edit_charge GET    /charges/:id/edit(.:format)             charges#edit
                 charge GET    /charges/:id(.:format)                  charges#show
                        PATCH  /charges/:id(.:format)                  charges#update
                        PUT    /charges/:id(.:format)                  charges#update
                        DELETE /charges/:id(.:format)                  charges#destroy

Debugging

Learn more about Pry here.

Misc

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