Created
June 24, 2011 06:04
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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