Skip to content

Instantly share code, notes, and snippets.

@mb-dev
mb-dev / posts_controller.rb
Last active December 11, 2015 12:39
Russian Doll Caching - Before - Controller
class PostsController < ApplicationController
def show
@post = Post.includes(comments: :user).find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @post }
end
end
end
@mb-dev
mb-dev / gist:1175448
Created August 27, 2011 14:23
LineItem model
class LineItem
include Mongoid::Document
include Mongoid::Timestamps
TYPE = %w[income expense]
INCOME = 0
EXPENSE = 1
TRANSFER_IN = 'Transfer In'
TRANSFER_OUT = 'Transfer Out'