app/controllers/communities_controller.rb
# One community and many collections were selected...
One community and many collections were selected
One community and many collections were selected
def make_editor
    @notices = []
    @errors = []
    params[:collection_id].each do |id|
      collection = Collection.find(id)
      if collection.watch_collection?
        @errors << I18n.t(:error_watch_collections_cannot_be_shared)
      elsif collection && current_user.can_edit_collection?(collection)
        collection.communities << @community
        log_action(:add_collection, collection_id: collection.id)
        @notices << I18n.t(:collection_was_added_to_community,
                           collection: link_to_collection(collection))
      else
        @errors << I18n.t(:error_couldnt_find_collection_by_id, id: id)
      end
    end
    flash.now[:errors] = @errors.to_sentence unless @errors.empty?
    flash[:notice] = @notices.to_sentence unless @notices.empty?
    respond_to do |format|
      format.html { redirect_to community_newsfeed_path(@community), status: :moved_permanently }
      format.js do
        convert_flash_messages_for_ajax
        render partial: 'shared/flash_messages', layout: false 
      end
    end
  end
def make_editor @notices = [ ] @errors = [ ] params [ :collection_id ] . each do | id | collection = Collection . find ( id ) if collection . watch_collection? @errors << I18n . t ( :error_watch_collections_cannot_be_shared ) elsif collection && current_user . can_edit_collection? ( collection ) collection . communities << @community log_action ( :add_collection , collection_id : collection . id ) @notices << I18n . t ( :collection_was_added_to_community , collection : link_to_collection ( collection ) ) else @errors << I18n . t ( :error_couldnt_find_collection_by_id , id : id ) end end flash . now [ :errors ] = @errors . to_sentence unless @errors . empty? flash [ :notice ] = @notices . to_sentence unless @notices . empty? respond_to do | format | format . html { redirect_to community_newsfeed_path ( @community ) , status : :moved_permanently } format . js do convert_flash_messages_for_ajax render partial : 'shared/flash_messages' , layout : false end end end
One community and many collections were selected...
One community and many collections were selected ...
# JS will handle rendering these.