Recourse
Provides a new recourses method that can be invoked in a Rails app inside config/routes.rb
recourses is like resources on steroids for admin-only routes:
- All the routes are included in
Recourse.resourcesto easily display in a navbar - Their controllers do not need to define the
indexaction: they inherit a predefined one - There is also a predefined
index.htmlview which displays the resources paginated/searchable. - The content of each row can be customized defining a new
_row.html.erbpartial
How to install
- Add
gem 'resource'to theGemfilefile of your Rails app.
Available methods
In config/routes.rb:
recoursesinside the routes
In a resourceful Active Record model:
recourse_includes: the associations to include when fetching the resourcesrecourse_order: the SQL to sort the resources byrecourse_positionable?: whether the model has a position field to drag'n'drop sortrecourse_searchable?: whether the model has Ransack enabled for searches
Anywhere:
Recourse.resourcesto list all the routes