module Admin::AnnouncementsHelper def page_for_bulletin(bulletin) ann_page = nil pages = Page.where(:module=>'announcement') pages.each do |page| if page.categories.count ==1 if page.categories.include?(bulletin.category.id.to_s) ann_page = page end end break if !ann_page.nil? end if ann_page.nil? pages.each do |page| if page.categories.include?(bulletin.category.id.to_s) ann_page = page end break if !ann_page.nil? end end ann_page = pages.first if ann_page.nil? request.protocol+(request.host_with_port+ann_page.url+'/'+bulletin.to_param).gsub('//','/') rescue "/" end end