module Admin::PublicationsHelper def page_for_publication(publication) pub_page = nil pages = Page.where(:module=>'publication').select{|page| page.enabled_for.include?(I18n.locale.to_s)} pages.each do |page| if page.categories.count ==1 if (page.categories.include?(publication.category.id.to_s) rescue false) pub_page = page end end break if !pub_page.nil? end if pub_page.nil? pages.each do |page| if (page.categories.include?(publication.category.id.to_s) rescue false) pub_page = page end break if !pub_page.nil? end end pub_page = pages.first if pub_page.nil? request.protocol+(request.host_with_port+pub_page.url+'/'+publication.to_param).gsub('//','/') rescue "#" end end