Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
File.open("/data/my_app/shared/pids/my_app_job_runner.pid", "w") do |f|
f << Process.pid.to_s
end
`cd /data/my_app/current;/usr/bin/env HOME=/home/deploy RAILS_ENV=production rake jobs:work& > log/delayed_jobs.log`
require "spec/spec_helper"
class Bad
def self.deliver_message
raise "It broke."
end
end
class BadJob
def perform
module Delayed
class Worker
alias_method :original_handle_failed_job, :handle_failed_job
protected
def handle_failed_job(job, error)
say "Error Intercepted by Hoptoad..."
HoptoadNotifier.notify(error)
original_handle_failed_job(job,error)
end
gem install prologue
prologue new my_awesome_app
def index
render :json => @users
end
def as_json(options={})
super(:only => [:first_name,:last_name,:city,:state],
:include => {
:employers => {:only => [:title]},
:roles => {:only => [:name]}
}
)
end
[{
"user": {
"roles": [{
"name": "Admin"
}],
"city": "Boulder",
"last_name": "Schaafsma",
"employers": [{
"title": "Quick Left"
}],
def full_name
"#{first_name} #{last_name}"
end
def as_json(options={})
super(:only => [:city,:state],
:methods => [:full_name],
:include => {
:employers => {:only => [:title]},
:roles => {:only => [:name]}
}
)
end
[{
"user": {
"roles": [{
"name": "Admin"
}],
"city": "Boulder",
"employers": [{
"title": "Quick Left"
}],
"state": "CO",