Skip to content

Instantly share code, notes, and snippets.

# In Rails Controller
def playlist
@playlist = session[:playlist] = Playlist.new(current_user)
render :layout => false
end
# In RAILS view
xml.instruct! :xml, :version=>"1.0"
xml.playlist do
if @playlist.currently_playing?
deploy.task :default do
deploy.web.disable
backup_db # custom task to backup database
deploy.migrations
deploy.web.enable
deploy.cleanup
end
#!/usr/bin/env ruby
require "fileutils"
@current_path = File.dirname(__FILE__)
def database_config(branch)
"#{current_path}/../database_configs/#{branch}.yml"
end
class AuditHelper
def self.rebuild_from_audit(audit)
changes_in_order = Audit.find(:all, :conditions => ['auditable_id = ? AND auditable_type = ? AND version <= ?', audit.auditable_id, audit.auditable_type, audit.version], :order => "version")
current_attributes = {}
changes_in_order.each do |audit|
current_attributes.merge!(audit.changes || {})
current_attributes.merge!(:version => audit.version)
end
obj = audit.auditable_type.constantize.new(current_attributes)
audits = current_health.audits.find_all_by_created_at(day_helper.bae_of_day(day_of_month))
# this is needed for production. Otherwise detect doesn't work
audits.collect(&:changes)
return false if audits.empty?
audits.detect { |a| !a.changes["weight"].nil? }
class Foo < ActiveRecord::Base
belongs_to :user
private
##
# Override callbacks to audit users
##
def audit_create_callback
audit_create(user)
Server 'foo.elevatorup.com' as 'root'
'ruby' should be installed
'rails' should be installed
'git' version '1.6.1' should be installed
'php' version '5.x' should be installed
'php' version '4.x' should not be installed
Server 'bar.elevatorup.com' as 'root'
installed:
|'mysql' |'>=5.1'|
### Here
aoeu
## here 2
aoeu
## spec "should stop the director" (line 49), this is all the setup code in order:
# from line 3
@target = Example.new
# starting from line 8
@director = mock
@runner = mock
@runner.stubs(:prepare)
@director.stubs(:go?).returns false
We couldn’t find that file to show.