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 < ActiveRecord::Base | |
has_many :posts do | |
def find_or_create | |
first || create | |
end | |
end | |
end | |
class Post < ActiveRecord::Base | |
belongs_to :user |
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
# app/models/question_picker/base.rb | |
module QuestionPicker | |
class Base | |
end | |
end | |
# WTF? | |
# Expected .../app/models/question_picker/base.rb to define Base (LoadError) |
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
# .../activesupport-3.1.0/lib/active_support/dependencies.rb:490:in `load_missing_constant': Expected .../app/models/user/stuff.rb to define User::Stuff (LoadError) | |
# --- | |
# config/application.rb: | |
# Add model subdirectories. | |
config.autoload_paths += Dir[ | |
File.join(Rails.root, 'app', 'models', '**') | |
].reject { |f| !File.directory?(f) } | |
# --- |
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
# Same as deployment nginx configuration. | |
# No font/woff because it is already compressed: | |
# http://www.pixelastic.com/blog/87:gzipping-your-font-files | |
AssetHash::Base.gzip_types = %w( | |
application/javascript | |
application/json | |
application/xml | |
application/rss+xml | |
application/vnd.ms-fontobject |
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 Foo < ActiveRecord::Base | |
# extra_scss stored in DB | |
@@foo = File.join( | |
Rails.root, | |
'app', | |
'stylesheets', | |
'foo.scss' | |
) |
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
environment = { | |
"HOME" => "/root", | |
"PATH" => node.app[:path] | |
} | |
bash "kill almighty GOD!" do | |
user "root" | |
cwd "#{node.app[:deploy_to]}/current" | |
code "bin/god terminate; sleep 10" | |
environment environment |
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
var midoverlay = $("#middle-overlay").hide(); | |
if ("pointerEvents" in document.createElement("div").style) { | |
midoverlay.show(); | |
// Some browsers think they support it, but really do not... (Opera, I'm looking at you) | |
setTimeout(function () { | |
var offset, test; | |
offset = midoverlay.offset(); | |
test = document.elementFromPoint(offset.left + 1, offset.top + 1); | |
if (!test || test.id === "middle-overlay") { | |
midoverlay.hide(); |
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
server { | |
listen 443; | |
ssl on; | |
server_name foo.com; | |
root /home/app/public; | |
location / { | |
# 503s from haproxy do not display /errors/503.html... | |
proxy_pass http://haproxy; |
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
# lib/asset_fingerprints.rb -- A hack to get asset_hash to play nice with Rails 2.3.11 (since there is no ActionController::Base.asset_path configuration option). | |
# Same as deployment nginx configuration. | |
# No font/woff because it is already compressed: | |
# http://www.pixelastic.com/blog/87:gzipping-your-font-files | |
AssetHash::Base.gzip_types = %w( | |
application/javascript | |
application/json | |
application/xml |
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
location ~* -[0-9a-f]{32}\.(ico|css|js|gif|jpe?g|png|eot|ttf|otf|woff|svg)(\.gz)?$ { | |
expires max; | |
} | |
#=> nginx: [emerg] unknown directive "32}\.(ico|css|js|gif|jpe?g|png|eot|ttf|otf|woff|svg)(\.gz)?$ | |
# ahh of course... have to escape the brackets for nginx's parser: | |
location ~* "-[0-9a-f]{32}\.(ico|css|js|gif|jpe?g|png|eot|ttf|otf|woff|svg)(\.gz)?$" { | |
expires max; |