You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i have helper method that renders main navigation if it exists and all the pages in other case, also added admin page link if current user is admin
def render_main_menu
main_navigation = Storytime::Navigation.find_by(handle: "main")
menu_html = if main_navigation
render main_navigation
else
Storytime::Page.published.collect do |page|
content_tag :li do
link_to page.title, storytime.page_path(page)
end
end
end
if current_user&.admin?
menu_html << content_tag(:li) do
link_to t('defaults.admin'), storytime_admin_path
end
end
menu_html.html_safe
end
feel free to use it :)
i think that would be nice to include helper method like this to the core @bcroesch ?
in User model i have:
def roles
storytime_roles
end
def admin?
roles.pluck(:name).include? ('admin')
end
Currently the pages are added to the navigation based on when it was publish.
The text was updated successfully, but these errors were encountered: