ask/app/helpers/admin/asks_helper.rb

28 lines
709 B
Ruby

module Admin::AsksHelper
def page_for_askquestion(askquestion)
ann_page = nil
pages = Page.where(:module=>'ask')
pages.each do |page|
if page.categories.count ==1
if page.categories.include?(askquestion.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?(askquestion.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+'/'+askquestion.to_param).gsub('//','/') rescue "/"
end
end