Skip to content

Instantly share code, notes, and snippets.

@r38y
r38y / application_controller.rb
Created May 17, 2012 18:21 — forked from robotmay/application_controller.rb
Examples of low level caching
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter do
@categories = Rails.cache.fetch("global/categories", expires_in: 10.minutes) do
Category.where("posts_count > 0").all
end
end
end
@r38y
r38y / gist:1181971
Created August 30, 2011 20:46 — forked from zorn/gist:1181949
Trouble with nested content_tag in rails 3
In my app I made a helper method to help me render form rows and DRY up my code.
def form_row(form, input_type, symbol)
# Need to generate HTML like this
# <div class="clearfix">
# <%= f.label :first_name %>
# <div class="input">
# <%= f.text_field :first_name, html_options = {:class => 'xlarge'} %>
# </div>
# </div><!-- /clearfix -->
From bb2a78858cffa7c6937642986e9aca1a4f862c0d Mon Sep 17 00:00:00 2001
From: Ilya Grigorik <ilya@igvita.com>
Date: Thu, 10 Jun 2010 00:46:48 -0400
Subject: [PATCH] async rails3
---
Gemfile | 6 ++++++
app/controllers/widgets_controller.rb | 6 ++++++
app/models/widget.rb | 2 ++
config.ru | 1 +
RULES
* Contest starts at exactly 1PM EST on Friday, February 27, 2009
* Contest ends at exactly 5PM EST on Friday, February 27, 2009
* THREE winners will receieve an unpurchase-able Tikaro Gearxel Nerd Merit Badge
* ONE winner will receive a QRCode patch from http://p8tch.com (John's other project)
You can see pictures here:
http://www.flickr.com/photos/tikaro/3181563185/
HOW TO PLAY
* Take a picture that contains a Nerd Merit Badge somewhere in it, and post it