Files
grecia/docs/en/customization/components.md
Javi Martín f78e2bed94 Update documentation to load custom code
Just like mentioned in commit 6552e3197d, we need to use `load` instead
of `require_dependency` since we started using zeitwerk.
2024-06-28 03:49:20 +02:00

26 lines
1.0 KiB
Markdown

# Components
For components, customization can be used to change both the logic (included in a `.rb` file) and the view (included in a `.erb` file). If you only want to customize the logic for, let's say, the `Admin::TableActionsComponent`, create a file named `app/components/custom/admin/table_actions_component.rb` with the following content:
```ruby
load Rails.root.join("app", "components", "admin", "table_actions_component.rb")
class Admin::TableActionsComponent
# Your custom logic here
end
```
If, on the other hand, you also want to customize the view, you need a small modification. Instead of the previous code, use:
```ruby
class Admin::TableActionsComponent < ApplicationComponent; end
load Rails.root.join("app", "components", "admin", "table_actions_component.rb")
class Admin::TableActionsComponent
# Your custom logic here
end
```
This will make the component use the view in `app/components/custom/admin/table_actions_component.html.erb`. You can create this file and customize it to your needs.