Reserved model names and routes
When defining models in an Avo-powered application, certain names should be avoided as they are used by Avo’s internal controllers. Using these names may lead to conflicts, routing issues, or unexpected behavior.
Model names to avoid
Avo uses the following names for its internal controllers:
actionapplicationassociationattachmentbase_applicationbasechartdebughomeprivateresourcesearch
Using these names for models may override built-in functionality, cause routing mismatches, or introduce other conflicts.
Why these names are reserved
Avo relies on these names for its controller and routing system. For example:
resourceis essential for managing Avo resources.chartis used for analytics and visualizations.searchhandles search functionality.
Since Avo dynamically maps models and controllers, using these names may interfere with how Avo processes requests and displays resources.
Alternative approaches
If your application requires one of these names, consider the following alternatives:
- Use a prefix or suffix
user_resourceinstead ofresourceadvanced_searchinstead ofsearch
- Choose a synonym
graphinstead ofchart
Using Avo with existing models
If your application already has models with these names, you can generate an Avo resource with a different name while keeping the same model class.
For example for Resource run the following command:
bin/rails generate avo:resource user_resource --model-class resourceThis will generate:
Avo::Resources::UserResourceAvo::UserResourcesController
However, it will still use the existing Resource model, ensuring no conflicts arise.
Route Conflicts with resources :resources
If your application has a route definition like:
resources :resourcesThis will create path helpers such as resources_path, which conflicts with Avo’s internal routing helpers. Avo uses resources_path internally, and having this route in your application will override Avo’s default helpers, potentially breaking parts of the admin panel.
How to Fix It
To prevent conflicts, rename the route helpers to something more specific:
resources :resources, as: 'articles'This allows you to maintain the desired URL structure (/resources) without interfering with Avo’s internals.
Friendly.rb - Your friendly European Ruby Conference