Last active
August 29, 2015 13:59
-
-
Save suweller/10978651 to your computer and use it in GitHub Desktop.
Display menu items based on role-based access control
This file contains hidden or 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
app: | |
menu: | |
admin: | |
users: All users | |
manager: | |
users: My team |
This file contains hidden or 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
%ul.menu | |
%li= link_to( | |
= menu_item(:admin, User, id: 'people') | |
= menu_item(:manager, User, id: 'folks') | |
-# Some exceptions may need to be made... | |
- if current_user.persisted? | |
%li= link_to 'Sign out', destroy_user_session_path, method: :delete | |
- else | |
%li= link_to "Sign in", new_user_session_path | |
-# Resulting in: | |
<ul class='menu'> | |
<li id='people'><a href='/admin/users'>All users</a></li> | |
<li id='folks' class='active'><a href='/manager/users'>My team</a></li> | |
</ul> | |
<!-- etc... --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment