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
# Extracted from http://git.io/HeGfdA | |
# Full credit to https://github.com/SamSaffron | |
# | |
# Middleware that causes static asset requests to bypass rails altogether. This | |
# can make requests a lot faster. From 4.5s to 1.5s in some apps. Only relevant | |
# in development environments as production already does this. | |
# | |
# Put this file in lib/middleware and add the following code to your | |
# development.rb environment file: | |
# |
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
Steps to install and run PostgreSQL 9.3 using Homebrew (Mac OS X) | |
(if you aren't using version 9.2.4, change to the correct version) | |
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist | |
mv /usr/local/var/postgres /usr/local/var/postgres92 | |
brew upgrade postgresql | |
initdb /usr/local/var/postgres -E utf8 | |
pg_upgrade -b /usr/local/Cellar/postgresql/9.2.4/bin -B /usr/local/Cellar/postgresql/9.3.0/bin -d /usr/local/var/postgres91 -D /usr/local/var/postgres | |
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist |
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 CorsResponseHeaders | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
@status, @headers, @response = @app.call(env) | |
@headers['Access-Control-Allow-Origin'] = '*' | |
[@status, @headers, @response] | |
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
development: | |
adapter: postgresql | |
<% if `git symbolic-ref HEAD 2>/dev/null`.chomp.sub('refs/heads/', '').gsub(/\W/, '_') =~ /hotfix|release/ %> | |
database: YOUR_APP_NAME_HERE_development_master | |
<% else %> | |
database: YOUR_APP_NAME_HERE_development_<%= `git symbolic-ref HEAD 2>/dev/null`.chomp.sub('refs/heads/', '').gsub(/\W/, '_')[0..20] %> | |
<% end %> | |
pool: 5 | |
timeout: 5000 | |
host: localhost |
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
def set_deleted_at(value) | |
return self unless is_permanent? | |
record = self.class | |
record = record.unscoped if active_record_3? | |
record = record.find(id) | |
record.deleted_at = value | |
begin | |
# we call save! instead of update_attribute so an ActiveRecord::RecordInvalid | |
# error will be raised if the record isn't valid. (This prevents reviving records that | |
# disregard validation constraints,) |
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 UserObserver < ActiveRecord::Observer | |
def after_create(user) | |
UserObserver.welcome_user(user) | |
end | |
def self.welcome_user(user) | |
@user = user | |
UserMailer.welcome(user.id).deliver | |
CampaignMonitorSubscriber.new(@user).subscribe_to_news |