delete bulletin link if url is blank
This commit is contained in:
parent
4bce9e406c
commit
b768952070
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue