app/controllers/collections_controller.rb
# TODO - review these. There are too many and as a result there's some redundancy in, for example, checking whether the user is logged in on unpublished
# collections
review these. There are too many and as a result there's some redundancy in, for example, checking whether the user is logged in on unpublished
collections
review these . There are too many and as a result there ' s some redundancy in for example checking whether the user is logged in on unpublished collections
def create
    return must_be_logged_in unless logged_in?
    @collection = Collection.new(params[:collection])
    if @collection.description =~ EOL.spam_re or
      @collection.name =~ EOL.spam_re and
      current_user.newish?
      flash[:error] = I18n.t(:error_violates_tos)
      return redirect_to request.referer
    end
    if @collection.save
      @collection.users = [current_user]
      log_activity(activity: Activity.create)
      flash[:notice] = I18n.t(:collection_created_with_count_notice,
                              collection_name: link_to_name(@collection),
                              count: @collection.collection_items.count)
      if params[:source_collection_id] 
        return create_collection_from_existing
      else
        auto_collect(@collection)
        return create_collection_from_item
      end
    else
      flash[:error] = I18n.t(:collection_not_created_error, collection_name: @collection.name)
      return redirect_to request.referer
    end
    flash[:error] = I18n.t(:collection_not_created_error, collection_name: @collection.name)
    return redirect_to request.referer
  end
def create return must_be_logged_in unless logged_in? @collection = Collection . new ( params [ :collection ] ) if @collection . description =~ EOL . spam_re or @collection . name =~ EOL . spam_re and current_user . newish? flash [ :error ] = I18n . t ( :error_violates_tos ) return redirect_to request . referer end if @collection . save @collection . users = [ current_user ] log_activity ( activity : Activity . create ) flash [ :notice ] = I18n . t ( :collection_created_with_count_notice , collection_name : link_to_name ( @collection ) , count : @collection . collection_items . count ) if params [ :source_collection_id ] return create_collection_from_existing else auto_collect ( @collection ) return create_collection_from_item end else flash [ :error ] = I18n . t ( :collection_not_created_error , collection_name : @collection . name ) return redirect_to request . referer end flash [ :error ] = I18n . t ( :collection_not_created_error , collection_name : @collection . name ) return redirect_to request . referer end
TODO - review these.
TODO - review these .
# We got here by creating a new collection FROM an existing collection: # You shouldn't get here; something weird happened.