Skip to content

Instantly share code, notes, and snippets.

@dvander
Created March 7, 2014 08:13
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 dvander/9407433 to your computer and use it in GitHub Desktop.
Save dvander/9407433 to your computer and use it in GitHub Desktop.
# Render "namespace / project" where both components are separate links.
def render_project_link project
if !project.namespace
return link_to_project project do
project.name
end
end
if project.namespace.type == 'Group'
html = link_to group_path(id: project.namespace.path), class: 'group' do
content_tag(:span, "#{project.namespace.name}", class: 'group-name')
end
else
html = link_to user_path(project.namespace.path), class: 'user' do
content_tag(:span, "#{project.namespace.name}", class: 'user-name')
end
end
html << content_tag(:span, "/")
html << (link_to project_path(project) do
content_tag(:span, "#{project.name}", class: 'project-name')
end)
return html
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment