Skip to content

Instantly share code, notes, and snippets.

@tohagan
Created February 18, 2022 07:38
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 tohagan/d4261c883b9523ba240315adc7bfef20 to your computer and use it in GitHub Desktop.
Save tohagan/d4261c883b9523ba240315adc7bfef20 to your computer and use it in GitHub Desktop.
Rails Tabs example
<header class="row mb-3">
<div class="col-sm-12 col-md-6 text-primary">
<h2 class="mb-0 <%= level == 1 ? 'font-weight-bold' : ''%>"><%= title %></h2>
</div>
<ul class="nav nav-tabs justify-content-end col-sm-6 col-md-6 mt-2">
<% tabs.each do |tab| %>
<li class="nav-item">
<%= link_to tab[:label], tab[:path],
class: "nav-link #{(active == tab[:key] ? ' active font-weight-bold' : '')}"
%>
</li>
<%end %>
</ul>
</header>
<%= render partial: 'shared/nav_tabs', locals: {
level: 2,
active: active,
title: title,
tabs: [
{ :key => 'list', :label => 'List', :path => { action: 'index' } },
{ :key => 'add', :label => 'Add', :path => { action: 'new' } },
{ :key => 'import', :label => 'Import', :path => { action: 'import_new' } },
]
} %>
<%= render partial: 'shared/nav_tabs', locals: {
level: 1,
active: active,
title: "Manage Users",
tabs: [
{ :key => 'members', :label => 'Members', :path => { controller: 'sites/organizations/members', action: 'index' } },
{ :key => 'workers', :label => 'Workers', :path => { controller: 'sites/organizations/workers', action: 'index' } },
{ :key => 'finance-managers', :label => 'Finance Managers', :path => { controller: 'sites/organizations/finance_managers', action: 'index' } },
{ :key => 'administrators', :label => 'Administrators', :path => { controller: 'sites/organizations/admins', action: 'index' } },
]
} %>
<% title 'Import Members' %>
<%= render partial: 'shared/role_tabs', locals: { active: 'members' } %>
<%= render partial: 'shared/role_list_tabs', locals: { title: "Members", active: 'import' } %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment