Skip to content

Instantly share code, notes, and snippets.

@dangalipo
Created March 9, 2011 06:28
Show Gist options
  • Save dangalipo/861777 to your computer and use it in GitHub Desktop.
Save dangalipo/861777 to your computer and use it in GitHub Desktop.
helper or controller method?
def set_breadcrumbs_session(current, breadcrumbs)
if current.root?
breadcrumbs = [current.id]
else
parent_ids = []
current.parents.each{|c| parent_ids << c.id}
if parent_ids.include?(breadcrumbs.last)
breadcrumbs << current.id
else
if breadcrumbs.include?(current.id)
while breadcrumbs.last != current.id do
breadcrumbs.pop
end
else
breadcrumbs = nil
end
end
end
breadcrumbs
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment