Skip to content

Instantly share code, notes, and snippets.

@brand-it
Created June 24, 2011 06:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brand-it/1044306 to your computer and use it in GitHub Desktop.
Save brand-it/1044306 to your computer and use it in GitHub Desktop.
This is kinda of a basic little helper to tell you if the page that you are on is the one you were looking for
module ApplicationHelper
# A nice way to help the views tell if you are on the current page you want to be on.
def current_view(params, options = {})
results = options[:result] || "true"
valid = true
options.each do |option|
for param in params
if param[0].to_s == option[0].to_s
unless param[1].to_s == option[1].to_s
valid = false
end
end
if options[:ignore]
options[:ignore].each do |ignore|
if param[0].to_s == ignore[0].to_s && param[1].to_s == ignore[1].to_s
valid = false
elsif ignore[0].to_s == param[0].to_s && ignore[1].to_s == "all"
valid = false
end
end
end
end
end
if valid
return results
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment