Skip to content

Instantly share code, notes, and snippets.

A Capistrano Rails Guide

by Jonathan Rochkind, http://bibwild.wordpress.com

why cap?

Capistrano automates pushing out a new version of your application to a deployment location.

I've been writing and deploying Rails apps for a while, but I avoided using Capistrano until recently. I've got a pretty simple one-host deployment, and even though everyone said Capistrano was great, every time I tried to get started I just got snowed under not being able to figure out exactly what I wanted to do, and figured I wasn't having that much trouble doing it "manually".

Gem list reminder

Development

###pry-rails' Source : https://github.com/rweng/pry-rails

Description : Use pry instead of irb when you call rails console. Pry is a powerful alternative to the standard IRB shell for Ruby. It features syntax highlighting, a flexible plugin architecture, runtime invocation and source and documentation browsing.

###pry-doc' Source : https://github.com/pry/pry-doc

Web App Performance

Back End

N+1

  @users = User.all.includes(:profile) # SELECT * from users

Excessive joins/subselects or exta queries

# This is how you define your own custom exception classes
require 'pry'
class NoOrangesError < StandardError
end
class OrangeTree
attr_accessor :age, :height, :harvest
def initialize
// shorthand for $(document).ready();
$(function(){
//Your code...
$("form").on("submit", function(event) {
function checkLength(password) {
if(password.length < 8) {
errors.push("Your password must be at least 8 characters long.");
};
@jdubnicek
jdubnicek / form-validator.js
Created March 1, 2014 04:21 — forked from ksolo/form-validator.js
Form Validation
// shorthand for $(document).ready();
$(function(){
//Your code...
});

Instructions:

  1. Download this application skeleton.
  2. Convert the app to use AJAX.
  3. Add any files you changed to your gist and submit your code.
/* Here is your chance to take over Socrates!
Spend 10 minutes on each of the following hacks to the Socrates website.
Enter them in the console to make sure it works and then save
your results here.
Choose a new pair for each. Add your names to the section you complete.
*/
@jdubnicek
jdubnicek / zoo.js
Last active August 29, 2015 13:56 — forked from dbc-challenges/zoo.js
//------------------------------------------------------------------------------------------------------------------
// YOUR CODE: Create your Zoo "object literal" and Animal "constructor" and "prototypes" here.
//------------------------------------------------------------------------------------------------------------------
var Animal = function(name, numberOfLegs){
function animalName() {
return animal.animalName.toString;
};
function indentify() {
if (animalName = "Human" && animal.numberOfLegs == 2);
@jdubnicek
jdubnicek / zoo.js
Created February 17, 2014 03:17 — forked from dbc-challenges/zoo.js
//------------------------------------------------------------------------------------------------------------------
// YOUR CODE: Create your Zoo "object literal" and Animal "constructor" and "prototypes" here.
//------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------
// DRIVER CODE: Do **NOT** change anything below this point. Your task is to implement code above to make this work.
//------------------------------------------------------------------------------------------------------------------