Skip to content

Instantly share code, notes, and snippets.

@tonsV2
tonsV2 / gist:819459
Created February 9, 2011 22:29
Nested resources and pagination
route:
resources :muscle_groups do
resources :muscles
end
controller index method:
def index
if params[:muscle_group_id]
muscle_group_id = params[:muscle_group_id]
@tonsV2
tonsV2 / add_devise_columns_to_user.rb
Created February 9, 2011 01:47
Rails migration for adding devise columns to an existing user model
class AddDeviseColumnsToUser < ActiveRecord::Migration
def self.up
change_table :users do |t|
#if you already have a email column comment the below line
t.database_authenticatable
t.confirmable
t.recoverable
t.rememberable
t.trackable
t.string :encrypted_password, :limit => 128
@tonsV2
tonsV2 / create_cert.sh
Created August 21, 2010 23:16
Script used to create a self signed cert
#! /bin/bash
if [ -z "$1" ]; then
echo "Usage: $0 domain_name"
exit
fi
openssl req -new -newkey rsa:2048 -nodes -out $1.csr -keyout $1.key -subj "/C=DK/ST=Copenhagen/L=Noerrebro/O=my_company/CN=$1"
openssl x509 -req -days 365 -in $1.csr -signkey $1.key -out $1.crt
#! /bin/bash
if [ -z "$2" ]; then
echo “Usage: $0 domain_name ip[:port]“
exit
fi
#create cert
./create_cert $1