This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User | |
include Mongoid::Document | |
has_many :cars do | |
def find_or_foobar_by(attrs) | |
find_or_create_by(attrs) | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# See: https://github.com/mongoid/mongoid/blob/identity-map/spec/unit/mongoid/identity_map_spec.rb#L367 | |
# In order for the identity map to work when using fibers the | |
# entire unit of work must happen on the same fiber since it's using | |
# thread locals for storage. | |
# The following example is correct: | |
fiber = Fiber.new do | |
Person.find(id) | |
Person.find(id) # This query hits the identity map. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2.1.0-stable branch | |
Creating indexes... | |
Starting benchmark... | |
user system total real | |
[ Root Document Benchmarks ] | |
[ 1000 ] | |
#create 0.420000 0.010000 0.430000 ( 0.431558) | |
#each 0.040000 0.010000 0.050000 ( 0.040263) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module SimpleForm | |
class FormBuilder | |
alias _find_association_reflectio find_association_reflection | |
def find_association_reflection(association) #:nodoc: | |
if reflection = _find_association_reflectio(association) | |
ActiveModelMetadataProxy.new reflection | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
PATH=/sbin:/usr/sbin:/bin:/usr/bin | |
DESC="Resque worker" | |
NAME=resque | |
DAEMON=/usr/local/rvm/bin/rvm | |
DAEMON_ARGS="1.9.3@application exec rake resque:work" | |
DAEMON_DIR="/data/application" | |
PIDFILE=/var/run/$NAME/resque.pid | |
USER=vader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
check process redis | |
with pidfile /var/run/redis.pid | |
start program = "/etc/init.d/redis-server start" | |
stop program = "/etc/init.d/redis-server stop" | |
if failed host 127.0.0.1 port 6379 then restart | |
if 5 restarts within 5 cycles then timeout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
sudo rm -rf /usr/local/rvm/gems/ruby-1.9.3-p0@application/cache/ | |
set -e | |
cd .. | |
unset GIT_DIR | |
env -i git reset --hard | |
sudo /usr/local/rvm/bin/rvm 1.9.3@application exec bundle install | |
RAILS_ENV=staging RAILS_GROUPS=assets /usr/local/rvm/bin/rvm 1.9.3@application exec rake assets:precompile | |
/usr/local/rvm/bin/rvm 1.9.3@application exec rake db:seed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
PATH=/sbin:/usr/sbin:/bin:/usr/bin | |
DESC="Unicorn server" | |
NAME=unicorn | |
RVM=/usr/local/rvm/bin/rvm | |
RVM_EXEC_ARGS="1.9.3@application exec" | |
RAILS_DIR=/data/application | |
DAEMON=$RVM | |
DAEMON_ARGS="$RVM_EXEC_ARGS $RAILS_DIR/bin/unicorn -c $RAILS_DIR/config/unicorn.rb -E staging -D" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin | |
DAEMON=/usr/sbin/nginx | |
NAME=nginx | |
DESC=nginx | |
# Include nginx defaults if available | |
if [ -f /etc/default/nginx ]; then | |
. /etc/default/nginx | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
check process nginx | |
with pidfile "/var/run/nginx.pid" | |
start program = "/etc/init.d/nginx start" | |
stop program = "/etc/init.d/nginx stop" | |
if failed host 31.222.185.182 port 80 protocol http then restart | |
if 5 restarts within 5 cycles then timeout |