From b768952070e4d4a4e85233b2ba94a71bdd671a19 Mon Sep 17 00:00:00 2001 From: manson Date: Mon, 21 Jul 2014 11:01:53 +0800 Subject: [PATCH] delete bulletin link if url is blank --- app/controllers/admin/announcements_controller.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/controllers/admin/announcements_controller.rb b/app/controllers/admin/announcements_controller.rb index a1f3c36..656b46e 100644 --- a/app/controllers/admin/announcements_controller.rb +++ b/app/controllers/admin/announcements_controller.rb @@ -31,6 +31,12 @@ class Admin::AnnouncementsController < OrbitAdminController end def create + if !bulletin_params['bulletin_links_attributes'].nil? + bulletin_params['bulletin_links_attributes'].each do |idx,link| + bulletin_params['bulletin_links_attributes'].delete(idx.to_s) if link['url'].blank? + end + end + bulletin = Bulletin.new(bulletin_params) bulletin.create_user_id = current_user.id bulletin.update_user_id = current_user.id @@ -51,6 +57,13 @@ class Admin::AnnouncementsController < OrbitAdminController bulletin = Bulletin.find_by(:uid=>uid) bulletin_params[:tags] = bulletin_params[:tags].blank? ? [] : bulletin_params[:tags] bulletin_params[:email_member_ids] = bulletin_params[:email_member_ids].blank? ? [] : bulletin_params[:email_member_ids] + + if !bulletin_params['bulletin_links_attributes'].nil? + bulletin_params['bulletin_links_attributes'].each do |idx,link| + bulletin_params['bulletin_links_attributes'].delete(idx.to_s) if link['url'].blank? + end + end + bulletin.update_attributes(bulletin_params) bulletin.save build_email(bulletin)