Created
November 28, 2012 22:01
-
-
Save jraczak/4164977 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
| # abstracted code selection from tip.rb | |
| # 'date_age' is named arbitrarily | |
| def as_json(options = nil) | |
| methods = [] | |
| methods << :can_upvote if @current_user_id.present? | |
| methods << :date_age | |
| super(methods: methods, include: { user: { only: :username } }) | |
| end | |
| # calculate value to pass to JSON for availability in the partial | |
| def date_age | |
| time_ago_in_words(self.created_at) | |
| end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment