Skip to content

Instantly share code, notes, and snippets.

@morokhovets
Created October 20, 2011 19:20
Show Gist options
  • Save morokhovets/1302035 to your computer and use it in GitHub Desktop.
Save morokhovets/1302035 to your computer and use it in GitHub Desktop.
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