app/models/user.rb
# #collections is only a list of the collections the user *owns*.  This is a list that includes the collections the
# user has access to through communities
#
# NOTE - this will ALWAYS put the watch collection first.
collections is only a list of the collections the user *owns*.  This is a list that includes the collections the
user has access to through communities

this will ALWAYS put the watch collection first.
collections is only a list of the collections the user * owns * . This is a list that includes the collections the user has access to through communities this will ALWAYS put the watch collection first .
def all_collections(as_user = nil)
    @all_collections ||= {}
    return @all_collections[as_user] if @all_collections.has_key?(as_user)
    editable_collections = collections_including_unpublished.reject { |c| c.watch_collection? }
    editable_collections += Collection.joins(communities: :members).where(['user_id = ? AND manager = 1', id])
    editable_collections = [watch_collection] + editable_collections.sort_by { |c| c.name.downcase }.uniq
    if as_user.is_a?(User)
      editable_collections.delete_if { |c| ! as_user.can_read?(c) }
    else
      editable_collections.delete_if { |c| ! c.published? }
    end
    @all_collections[as_user] = editable_collections.compact
  end
def all_collections ( as_user = nil ) @all_collections ||= { } return @all_collections [ as_user ] if @all_collections . has_key? ( as_user ) editable_collections = collections_including_unpublished . reject { | c | c . watch_collection? } editable_collections += Collection . joins ( communities : :members ) . where ( [ 'user_id = ? AND manager = 1' , id ] ) editable_collections = [ watch_collection ] + editable_collections . sort_by { | c | c . name . downcase } . uniq if as_user . is_a? ( User ) editable_collections . delete_if { | c | ! as_user . can_read? ( c ) } else editable_collections . delete_if { | c | ! c . published? } end @all_collections [ as_user ] = editable_collections . compact end
collections is only a list of the collections the user *owns*.
collections is only a list of the collections the user * owns * .
as_user
<not_specific>