Created
September 4, 2013 19:35
-
-
Save dreamr/6441776 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
... | |
def feeds_counts | |
@result = [] | |
current_user.feeds.each do |feed| | |
@result << { | |
id: feed.id, | |
title: feed.title, | |
count: feed.post_count_since_last_read | |
} | |
end | |
respond_to do |format| | |
format.json { render json: @result } | |
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
... | |
def feeds_counts | |
respond_to do |format| | |
format.json { render json: (@result = current_user.feeds.map(&:to_feed_count_json)) } | |
end | |
end | |
... | |
class Feed < ActiveRecord::Base | |
... | |
def to_feed_count_json | |
{ | |
id: id, title: title, | |
count: post_count_since_last_read | |
} | |
end | |
... | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment