survey/app/helpers/admin/surveys_helper.rb

31 lines
882 B
Ruby
Raw Permalink Normal View History

2014-10-06 05:55:25 +00:00
module Admin::SurveysHelper
def page_for_survey(survey=nil)
ann_page = nil
pages = Page.where(:module=>'survey')
# 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?
if !survey.blank?
request.protocol+(request.host_with_port+ann_page.url+'/'+survey.to_param).gsub('//','/') rescue "/"
else
request.protocol+(request.host_with_port+'/'+I18n.locale.to_s+ann_page.url+'/').gsub('//','/') rescue "/"
end
end
end