delete bulletin link if url is blank

This commit is contained in:
manson 2014-07-21 11:01:53 +08:00
parent 4bce9e406c
commit b768952070
1 changed files with 13 additions and 0 deletions

View File

@ -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)