Skip to content

Instantly share code, notes, and snippets.

View delegate_matcher.rb
# RSpec matcher to spec delegations.
# Forked from https://gist.github.com/ssimeonov/5942729 with fixes
# for arity + custom prefix.
#
# Usage:
#
# describe Post do
# it { should delegate(:name).to(:author).with_prefix } # post.author_name
# it { should delegate(:name).to(:author).with_prefix(:any) } # post.any_name
# it { should delegate(:month).to(:created_at) }
@joeytheman
joeytheman / application_controller.rb
Created Oct 2, 2012 — forked from bgarret/application_controller.rb
Rack middleware and form tag patch to insert csrf tokens into cached pages
View application_controller.rb
class ApplicationController < ActionController::Base
TOKEN_PLACEHOLDER = "__CROSS_SITE_REQUEST_FORGERY_PROTECTION_TOKEN__"
before_filter :form_authenticity_token
after_filter :inject_csrf_token
private
def inject_csrf_token
if protect_against_forgery? && token = session['_csrf_token']