35 lines
857 B
Ruby
Raw Normal View History

2014-09-14 16:00:41 -07:00
module NavigationHelpers
2015-08-18 22:18:29 -07:00
def path_to(path)
path = path.to_sym
case path
2014-09-14 16:00:41 -07:00
when /^landing$/i
path = :home
2014-09-14 16:00:41 -07:00
when /^registration$/i
2015-08-18 22:18:29 -07:00
path = "/conferences/#{@last_conference.slug}/register/"
when /^edit conference$/i
path = "/conferences/#{@last_conference.slug}/edit/"
2015-08-18 22:18:29 -07:00
when /^(workshops|stats|broadcast)$/i
path = "/conferences/#{@last_conference.slug}/#{path}/"
2015-10-11 08:56:02 -07:00
when /^(stats.xls)$/i
path = "/conferences/#{@last_conference.slug}/stats.xls"
2014-09-14 16:00:41 -07:00
end
if path.is_a?(Symbol)
begin
2015-08-18 22:18:29 -07:00
path = Rails.application.routes.url_helpers.send("#{path}_path".to_sym)
2014-09-14 16:00:41 -07:00
rescue Object => e
2015-08-18 22:18:29 -07:00
raise "Can't find mapping from \"#{path}\" to a path."
2014-09-14 16:00:41 -07:00
end
end
2015-08-18 22:18:29 -07:00
if path.blank?
raise "Can't find mapping from \"#{page_name}\" to a path."
end
return path
2014-09-14 16:00:41 -07:00
end
end
World(NavigationHelpers)