0.0
No release in over a year
Add a :nav option to Rails routes mapper 'resources' method, that adds the resource to an array. It can be used to populate a navigation menu.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 7.0, >= 7.0.3
 Project Readme

Resources Nav

Add a :nav option to Rails routes mapper 'resources' method, that adds the resource to an array. It's convenient to populate a navigation menu.

Usage

Just add a nav option to your resources route in config/routes.rb. The nav option can take a hash, containing an icon name.

Rails.application.routes.draw do
  resources :apples, nav: true
  resources :oranges, nav: true
  resources :apricots, nav: { icon: 'fruit' }
end

The resources array will then be accessible from Rails.application.routes.resources_nav:

Rails.application.routes.resources_nav.map(&:name)
=> [:apples, :oranges, :apricots]

resource = Rails.application.routes.resources_nav.detect { |r| r == :apricots }

resource.name
=> :apricots

resource.icon
=> 'fruit'

Installation

Add this line to your application's Gemfile:

gem "resources_nav"

And then execute:

$ bundle

Or install it yourself as:

$ gem install resources_nav

Contributing

Feel free to submit issues or pull requests!

License

The gem is available as open source under the terms of the MIT License.