Here's what I did to get things working.
Yep, over at: https://developer.apple.com
# See: | |
# * http://thepugautomatic.com/2014/03/simpledelegator-autoloading-issues-with-rails/ | |
# * https://groups.google.com/forum/#!topic/rubyonrails-core/PjGUK72BmFA | |
# * https://gist.github.com/henrik/9314943 | |
require "delegate" | |
class RailsCompatibleSimpleDelegator < SimpleDelegator | |
def self.const_missing(name) | |
if ::Object.const_defined?(name) |
#!/usr/bin/env ruby | |
puts "Run this in another terminal:" | |
puts "" | |
puts " sudo ./trace-gc-standalone.sh #{$$}" | |
puts "" | |
puts "... wait for the 'Ready!' message, switch back here and press enter to start." | |
GC::Profiler.enable | |
$stdin.gets |
define(function(){ | |
var instance = null; | |
function MySingleton(){ | |
if(instance !== null){ | |
throw new Error("Cannot instantiate more than one MySingleton, use MySingleton.getInstance()"); | |
} | |
this.initialize(); | |
} |
Here's what I did to get things working.
Yep, over at: https://developer.apple.com
# :PROCESS: ruby, "ruby %f 2>&1" | |
# :BRACKET_CODE: "[ruby]", "[/ruby]" | |
# :TEXT: | |
# | |
# In the <a | |
# href="http://devver.net/blog/2009/06/a-dozen-or-so-ways-to-start-sub-processes-in-ruby-part-1/">previous | |
# article</a> we looked at some basic methods for starting subprocesses in Ruby. | |
# One thing all those methods had in common was that they didn't permit a lot of | |
# communication between parent process and child. In this article we'll examine | |
# a few built-in Ruby methods which give us the ability to have a two-way |
require 'rubygems' | |
require 'rack' | |
class Object | |
def webapp | |
class << self | |
define_method :call do |env| | |
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?) | |
[200, {}, send(func, *attrs)] | |
end |
desc "creates database & database user" | |
task :create_database do | |
set :root_password, Capistrano::CLI.password_prompt("MySQL root password: ") | |
set :db_user, Capistrano::CLI.ui.ask("Application database user: ") | |
set :db_pass, Capistrano::CLI.password_prompt("Password: ") | |
set :db_name, Capistrano::CLI.ui.ask("Database name: ") | |
run "mysql --user=root --password=#{root_password} -e \"CREATE DATABASE IF NOT EXISTS #{db_name}\"" | |
run "mysql --user=root --password=#{root_password} -e \"GRANT ALL PRIVILEGES ON #{db_name}.* TO '#{db_user}'@'localhost' IDENTIFIED BY '#{db_pass}' WITH GRANT OPTION\"" |
class ActiveRecord::Base | |
def can_destroy? | |
self.class.reflect_on_all_associations.all? do |assoc| | |
assoc.options[:dependent] != :restrict || (assoc.macro == :has_one && self.send(assoc.name).nil?) || (assoc.macro == :has_many && self.send(assoc.name).empty?) | |
end | |
end | |
end |
desc "precompile the assets" | |
task :precompile_assets, :roles => :web, :except => { :no_release => true } do | |
run "cd #{current_path}; rm -rf public/assets/*" | |
run "cd #{current_path}; RAILS_ENV=production bundle exec rake assets:precompile" | |
end |
There are two Rails issues in it's handling of the HTTP Accept
header which cause a number of spurious exception emails via Airbrake. I am encountering this on Rails 3.0.7. One of these is fixed in a later version of Rails, but for other reasons I can't upgrade right now. The other bug is still present in Rails 3.2 and in master at the time of this writing. This gist includes some monkey patches you can apply to fix these issues until such time that they are fixed in Rails properly.
Issue #736 is that Rails does not correctly parse a q-value in an Accept header when there is only one content-type specified. For example:
Accept: text/html;q=0.9