app/models/user.rb
# Checks to see if one already exists (DO NOT use #watch_collection to do this, recursive!), and builds one if not:
Checks to see if one already exists (DO NOT use #watch_collection to do this, recursive!), and builds one if not.
Checks to see if one already exists ( DO NOT use #watch_collection to do this recursive! ) and builds one if not .
def build_watch_collection
    c = Collection.count_by_sql("SELECT COUNT(*) FROM collections c JOIN collections_users cu ON (c.id = cu.collection_id) WHERE cu.user_id = #{self.id} AND c.special_collection_id = #{SpecialCollection.watch.id}")
    if c == 0
      collections << collection = Collection.create(name: I18n.t(:default_watch_collection_name, username: self.full_name.titleize), special_collection_id: SpecialCollection.watch.id)
      return collection
    end
    return nil 
  end
def build_watch_collection c = Collection . count_by_sql ( "SELECT COUNT(*) FROM collections c JOIN collections_users cu ON (c.id = cu.collection_id) WHERE cu.user_id = #{self.id} AND c.special_collection_id = #{SpecialCollection.watch.id}" ) if c == 0 collections << collection = Collection . create ( name : I18n . t ( :default_watch_collection_name , username : self . full_name . titleize ) , special_collection_id : SpecialCollection . watch . id ) return collection end return nil end
Checks to see if one already exists (DO NOT use #watch_collection to do this, recursive!
Checks to see if one already exists ( DO NOT use #watch_collection to do this recursive!
# Didn't build one.