app/controllers/communities_controller.rb
# One collection and many communities were selected...
One collection and many communities were selected
One collection and many communities were selected
def make_editors
    @notices = []
    @errors = []
    collection = Collection.find(params[:collection_id])
    if collection.watch_collection?
      @errors << I18n.t(:error_watch_collections_cannot_be_shared)
    else
      params[:community_id].each do |id|
        community = Community.find(id)
        if community && current_user.can_manage_community?(community)
          collection.communities << community
          log_action(:add_collection, community: community, collection_id: collection.id)
          @notices << I18n.t(:community_can_now_manage_this_collection,
                             community: link_to_name(community))
        else
          @errors << I18n.t(:error_couldnt_find_community_by_id, id: id)
        end
      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 collection, status: :moved_permanently }
      format.js do
        convert_flash_messages_for_ajax
        render partial: 'shared/flash_messages', layout: false 
      end
    end
  end
def make_editors @notices = [ ] @errors = [ ] collection = Collection . find ( params [ :collection_id ] ) if collection . watch_collection? @errors << I18n . t ( :error_watch_collections_cannot_be_shared ) else params [ :community_id ] . each do | id | community = Community . find ( id ) if community && current_user . can_manage_community? ( community ) collection . communities << community log_action ( :add_collection , community : community , collection_id : collection . id ) @notices << I18n . t ( :community_can_now_manage_this_collection , community : link_to_name ( community ) ) else @errors << I18n . t ( :error_couldnt_find_community_by_id , id : id ) end 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 collection , status : :moved_permanently } format . js do convert_flash_messages_for_ajax render partial : 'shared/flash_messages' , layout : false end end end
One collection and many communities were selected...
One collection and many communities were selected ...
# JS will handle rendering these.