origin: jerodsanto Blog
Since Rails 3 you’ve been able to configure an app to handle exceptions, which you want to point right at your router. To do this, add the following to config/application.rb:
# Monkey patch for the Rails plugin "acts_as_taggable_on" to handle dirty tracking | |
# http://github.com/mbleigh/acts-as-taggable-on/issues#issue/1 | |
module ActsAsTaggableOn::Taggable | |
module Core | |
module InstanceMethods | |
def set_tag_list_on_with_dirty_tracking(context,new_list) | |
value = new_list.to_s | |
attr = "#{context.to_s.singularize}_list" | |
namespace :assets do | |
desc "Check that all assets have valid encoding" | |
task :check => :environment do | |
paths = ["app/assets", "lib/assets", "vendor/assets"] | |
extensions = ["js", "coffee", "css", "scss"] | |
paths.each do |path| | |
dir_path = Rails.root + path |
class MagicString < String | |
def +@ | |
upcase | |
end | |
def -@ | |
downcase | |
end | |
def ~ |
namespace :deploy do | |
namespace :assets do | |
task :precompile, :roles => :web, :except => { :no_release => true } do | |
from = source.next_revision(current_revision) | |
if capture("cd #{latest_release} && #{source.local.log(from)} vendor/assets/ app/assets/ | wc -l").to_i > 0 | |
run %Q{cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:precompile} | |
else | |
logger.info "Skipping asset pre-compilation because there were no asset changes" | |
end | |
end |
require 'rubygems' | |
require 'freeagent' | |
require 'eventmachine' | |
require 'em-synchrony' | |
require 'em-http-request' | |
require 'em-synchrony/fiber_iterator' | |
require 'active_support' | |
ATTACHMENTS_DIR = '/Users/steve/Documents/freeagent_attachments' |
# Dynamic method stubbing | |
# user = Factory(:user) | |
# callbacks = User._create_callbacks.map(&:filter) | |
# stub_methods("user", callbacks) | |
def stub_methods(name, methods) | |
methods.each do |method| | |
eval "stub(#{name}).#{method}" | |
end | |
end |
#!/bin/sh | |
exec 2>&1 | |
export RAILS_ENV=production | |
APP_ROOT=/home/deploy/project_name | |
UNICORN="/usr/local/rvm/bin/rvm 1.9.2@project_name exec bundle exec unicorn_rails -c $APP_ROOT/current/config/unicorn.rb -E $RAILS_ENV" | |
cd $APP_ROOT/current | |
exec $UNICORN |
files = Dir["./**/*"] | |
files.each do |file| | |
next if File.directory?(file) | |
words = [] | |
begin | |
File.read(file).scan /[\u0400-\u04FF\-]+/ do |match| | |
words << match | |
end |
origin: jerodsanto Blog
Since Rails 3 you’ve been able to configure an app to handle exceptions, which you want to point right at your router. To do this, add the following to config/application.rb:
#!/usr/bin/env jruby | |
# | |
# | |
require 'rubygems' | |
require 'spoon' | |
EXEC = '/tmp/exec.rb' | |
PID_PATH = '/tmp/exec.pid' | |
WORK_PATH = '/tmp/' |