Created
April 8, 2012 15:22
-
-
Save anonymous/2337940 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'feedable.rb' | |
class ApplicationModel < ActiveRecord::Base | |
extend Feedable | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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