Last active
December 15, 2015 23:06
-
-
Save mayra-cabrera/49c70b723085bd20605c 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
class PostDecorator | |
attr_reader :post | |
def initialize post | |
@post = post | |
end | |
def recent? | |
published_at > 2.days.ago | |
end | |
end | |
class PostsController < ApplicationController | |
def show | |
post = Post.find(params[:id]) | |
@post = PostDecorator.new post | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment