Skip to content

Instantly share code, notes, and snippets.

@raghubetina
raghubetina / ransack.md
Last active May 31, 2024 16:36
Ransack Cheatsheet

Ransack Cheatsheet

The Ransack gem provides us with a powerful, flexible, easy-to-integrate search/filter form.

Installation

In your Gemfile, include

gem 'ransack'
@raghubetina
raghubetina / rcav.md
Last active December 25, 2017 20:53
RCAV Flowchart

RCAV Flowchart

Our apps are nothing more than a collection of URLs that we decide to allow users to access:

  • mydomain.com/products
  • mydomain.com/photos/193
  • mydomain.com/signin

So remember: everything always starts with a route between a URL we want to support and a Ruby method that will be responsible for generating a response to the user's browser.

@raghubetina
raghubetina / rails_basics.md
Last active December 25, 2017 20:53
Rails Basic Commands

Rails Basic Commands

Generate or Clone an application

Generate a brand new application

cd to the folder where you want to store your new application. For me, this is ~/code. Then,

rails new my_app
@raghubetina
raghubetina / command_line.md
Last active December 25, 2017 20:52
Command Line Cheatsheet

Command Line Cheatsheet

See what folder you are currently in

Mac

The "print working directory" command:

@raghubetina
raghubetina / heroku.md
Last active January 5, 2024 04:40
Heroku Cheatsheet

Heroku Cheatsheet

Get the Heroku toolbelt

Sign up for a Heroku account and install the toolbelt if you haven't already.

Prepare your application

In your Gemfile, add

@raghubetina
raghubetina / github.md
Last active August 7, 2021 14:47
Getting Started With GitHub

Getting Started With GitHub

Pulling Code Down from GitHub.com

We're going to use GitHub for all of our code-sharing and submission.

Vocab

All of our apps are just a folder with some files (maybe some HTML files, some CSS files, etc) and other folders in it. We call the top-level folder a "repository". You'll find the list of the repositories we'll work on during this course on the organization page (your course org is probably called something like appdevwinter2017):

@raghubetina
raghubetina / devise.md
Last active July 13, 2019 20:35
Devise Cheatsheet

Authentication and Authorization with Devise

We will be using the [Devise gem][2] to help us get started with authentication (are you who you say you are?) and authorization (are you allowed to do/see this?).

Add sign-in/sign-out

  • Add gem 'devise' to your Gemfile and bundle
  • rails g devise:install

Devise will give you some setup instructions. We don't need to worry about most of them, but we do need to set a root URL. Usually, you will point the root URL to the index action of some important resource in your application: In config/routes.rb:

@raghubetina
raghubetina / starter_generators.md
Last active December 25, 2017 20:54
starter_generators Cheatsheet

starter_generators Cheatsheet

Include this in Gemfile, which is a file located in the root folder of your app:

# Gemfile

gem "starter_generators", :git => "http://github.com/raghubetina/starter_generators.git"
@raghubetina
raghubetina / crud_with_ruby.md
Last active March 4, 2019 14:36
CRUD with Ruby

CRUD with Ruby

Here is a quick reference on how to insert, retrieve, update, and delete rows from your database tables using our ActiveRecord-backed Ruby classes.

Adding Tables to the Database

First, we need a Ruby class to represent the real-world thing we're trying to model, and we need an underlying database table to store information about each individual thing.

Rails includes an easy generator to help us get set up with both of these things quickly. Supposed I wanted to create a table to store instructors, with two string columns first_name and last_name. I could use this shortcut from the Command Line:

@raghubetina
raghubetina / terminal_prompt.md
Last active October 9, 2015 11:43
Customizing Your Terminal Prompt

Customizing Your Terminal Prompt

tl;dr

Run the following command from anywhere in Terminal:

echo PS1=\"\\w $ \" >> ~/.bash_profile