Created
October 20, 2011 19:20
-
-
Save morokhovets/1302035 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 index | |
scope = if current_user | |
case @filter | |
when :all; Post.not_private.unfiltered | |
when :all_unread; Post.not_private.unread(current_user) | |
when :restricted; Post.not_private.restricted | |
when :unrestricted; Post.not_private.unrestricted | |
when :interesting; Post.not_private.interesting(current_user) | |
when :my; Post.not_private.has_unread_comments(current_user).my(current_user) | |
when :my_all; Post.not_private.my(current_user) | |
when :inbox; Post.not_not_private.accessible_by(current_user) | |
else Post.not_private.unfiltered | |
end | |
else | |
Post.not_private.unrestricted | |
end | |
scope = scope.not_hidden unless current_user && current_user.is_admin? | |
@posts = scope.descend_by_created_at.paginate :page => params[:page], :include => :user | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment