Skip to content

Instantly share code, notes, and snippets.

dignoe / after_restart.rb
Created Mar 8, 2017
Automatic maintenance page on migrate with AWS OpsWorks + Rails
View after_restart.rb
# Disable maintenance page"Disabling maintenance page")
file "/srv/www/your_app/shared/system/maintenance.html" do
action :delete
dignoe / will_paginate_helper.rb
Last active Sep 7, 2016
Add rel="next" & rel="prev" to will_paginate gem (with custom paths)
View will_paginate_helper.rb
# config/initializers/will_paginate_helper.rb
# Tested with will_paginate v3.0.7
module WillPaginate
module ActionView
class LinkRenderer < ViewHelpers::LinkRenderer
include ListingHelper
def url(page)
dignoe / gist:3989505
Created Oct 31, 2012
Redirect all domains to specified domain in Rails 3
View gist:3989505
MyApp::Application.routes.draw do
if Rails.env.production?
constraints(:host => /^(?!www\.my-domain\.com)/) do
match "(*path)" => redirect { |params, request| URI.parse(request.url).tap { |x| = "" }.to_s}
dignoe / gist:2485272
Created Apr 25, 2012
Patch to get content_for working with action caching and fragment caching in Rails 3.1
View gist:2485272
module ActionController
class Metal
attr_internal :cached_content_for
module Caching
module Actions
def _save_fragment(name, options)
return unless caching_allowed?