Skip to content

Instantly share code, notes, and snippets.

# mongo_template.rb
# fork of Ben Scofield's Rails MongoMapper Template (http://gist.github.com/181842)
#
# To use:
# rails project_name -m http://gist.github.com/gists/219223.txt
# remove unneeded defaults
run "rm public/index.html"
run "rm public/images/rails.png"
run "rm public/javascripts/controls.js"
class SomeController < ApplicationController
layout "some_layout", :only => [:new, :edit]
...
end
#=> renders all actions, other than new and edit, with no layout.
class SomeController < ApplicationController
def edit
...
render :layout => "some_layout"
file 'Gemfile', <<-GEMS
source 'http://gemcutter.org'
gem "rails", "3.0.0.beta3"
gem "bson_ext", '0.20.1'
gem "mongoid", "2.0.0.beta4"
gem "compass", "0.10.0.rc5"
group :test do
gem "rspec-rails", "2.0.0.beta.8"
gem "capybara"
table {
border-spacing: 0;
width: 100%; }
table th {
color: #555555;
padding: 1em 0.5em;
text-align: left;
background-color: #a7d3ff; }
table td {
padding: 7px 3em 7px 0.5em; }
module ActionView::Helpers::AssetTagHelper
remove_const :JAVASCRIPT_DEFAULT_SOURCES
JAVASCRIPT_DEFAULT_SOURCES = %w(http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js rails.js)
reset_javascript_include_default
end
module ActionView::Helpers::AssetTagHelper
self.register_javascript_expansion :jquery => ["http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js", "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js", "rails.js", "application.js"]
end
# Bash snippet to open new shells in most recently visited dir.
# Useful if you want to open a new terminal tab at the present
# tab's location.
#
# Put this in your .bashrc or whatever.
pathed_cd () {
if [ "$1" == "" ]; then
cd
else
gideon:beyond_the_shock eh$ cap staging deploy
triggering start callbacks for `staging'
* executing `moonshine:configure'
* executing `staging'
triggering start callbacks for `deploy'
* executing `moonshine:configure'
* executing `multistage:ensure'
triggering after callbacks for `multistage:ensure'
* executing `moonshine:configure_stage'
* executing `deploy'
@erichurst
erichurst / User.rb
Created February 2, 2012 17:40
Custom callback notification with Rails 3
class User < ActiveRecord::Base
...
def self.new_sitter(user, params)
if user.parent?
transaction do
sitter = create! do |u|
u.sub_type = 'sitter'
u.first_name = params[:first_name]
u.last_name = params[:last_name]
u.email = params[:email]
@erichurst
erichurst / .irbrc
Created July 1, 2011 03:27
Pimp Your IRB
# Make gems available
require 'rubygems'
begin
require "ap"
alias pp ap
rescue LoadError
puts "Please install the 'awesome_print' gem."
end