Skip to content

Instantly share code, notes, and snippets.

View georgismitev's full-sized avatar

Georgi Mitev georgismitev

  • Zurich, Switzerland
View GitHub Profile
# 0. Make sure you have Ruby 1.9.3 installed, and optionally RVM and PostgreSQL
# 0.2 If you are on the Mac, make sure you have a c compiler by installing XCode Command Line Tools or gcc4.2 with homebrew
# https://github.com/mxcl/homebrew/wiki/Custom-GCC-and-cross-compilers
# 0.5 Make sure you have bundler version ~> 1.2 as Rails depends on it
gem install bundler
# 1. Get edge Rails source (master branch)
git clone https://github.com/rails/rails.git
# Some good references are:
# http://russbrooks.com/2010/11/25/install-postgresql-9-on-os-x
# http://www.paolocorti.net/2008/01/30/installing-postgis-on-ubuntu/
# http://postgis.refractions.net/documentation/manual-1.5/ch02.html#id2630392
#1. Install PostgreSQL postgis and postgres
brew install postgis
initdb /usr/local/var/postgres
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

Friendly URLs

By default, Rails applications build URLs based on the primary key -- the id column from the database. Imagine we have a Person model and associated controller. We have a person record for Bob Martin that has id number 6. The URL for his show page would be:

/people/6

But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6 here, is called the "slug". Let's look at a few ways to implement better slugs.

Deploy Rails app to digitalocean with nginx, unicorn, capistrano & postgres

Create droplet of your liking (ubuntu 12.10 x32)

ssh to root in terminal with your server ip

ssh root@123.123.123.123

Add ssh fingerprint and enter password provided in email

<% flash.each do |type, message| %>
<div class="alert <%= bootstrap_class_for(type) %> fade in">
<button class="close" data-dismiss="alert">×</button>
<%= message %>
</div>
<% end %>
#!/usr/bin/env bash
curl https://s3.amazonaws.com/heroku-jvm-buildpack-vi/vim-7.3.tar.gz --output vim.tar.gz
mkdir vim && tar xzvf vim.tar.gz -C vim
export PATH=$PATH:/app/vim/bin
:set nocompatible " Use Vim defaults (much better!)

This is for those having trouble with the 'designmodo-flatuipro-rails' gem in a rails app when using Capistrano for deployment.

This gem required that we use the 'less' gem in conjunction with the 'bootstrap-on-rails' gem. This bootstrap gem is the Less version.

The error we are dealing with is this: couldn't find file 'jquery.ui.touch-punch.min'

All of the work will be done in the 'config/deploy.rb' file

after "deploy:bundle_gems", "deploy:flat_ui"
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
"googleanalytics","google-analytics.com/ga.js"
"quantcast",".quantserve.com/quant.js"
"comscore","http://int.sitestat.com/comscore/"
"omniture","<!-- SiteCatalyst"
"facebook","<meta property=""fb:app_id"" conten"
"chartbeat","static.chartbeat.com/js/chartbeat.js"
"googleecom","google_conversion_id"
"floodlight","https://fls.doubleclick.net/activityi"
"nielsen","imrworldwide.com"
"webtrends","dcsMultiTrack"