Skip to content

Instantly share code, notes, and snippets.

Created April 8, 2012 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/2337940 to your computer and use it in GitHub Desktop.
Save anonymous/2337940 to your computer and use it in GitHub Desktop.
require 'feedable.rb'
class ApplicationModel < ActiveRecord::Base
extend Feedable
end
module Feedable
def act_as_feedable
send :extend, ClassMethods
end
module ClassMethods
def feed(last)
self.where("created_at < ? ", last).order('created_at desc').limit(5)
end
end
end
class Verso < ApplicationModel
act_as_feedable
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment