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.
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
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:
|
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
|
```ruby
|
||||||
require_dependency Rails.root.join("app", "components", "admin", "table_actions_component").to_s
|
load Rails.root.join("app", "components", "admin", "table_actions_component.rb")
|
||||||
|
|
||||||
class Admin::TableActionsComponent
|
class Admin::TableActionsComponent
|
||||||
# Your custom logic here
|
# Your custom logic here
|
||||||
@@ -15,7 +15,7 @@ If, on the other hand, you also want to customize the view, you need a small mod
|
|||||||
```ruby
|
```ruby
|
||||||
class Admin::TableActionsComponent < ApplicationComponent; end
|
class Admin::TableActionsComponent < ApplicationComponent; end
|
||||||
|
|
||||||
require_dependency Rails.root.join("app", "components", "admin", "table_actions_component").to_s
|
load Rails.root.join("app", "components", "admin", "table_actions_component.rb")
|
||||||
|
|
||||||
class Admin::TableActionsComponent
|
class Admin::TableActionsComponent
|
||||||
# Your custom logic here
|
# Your custom logic here
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ If you need to create new models or customize existent ones, you can do it so at
|
|||||||
For example for Madrid's City Hall fork its required to check the zip code's format (it always starts with 280 followed by 2 digits). That check is at `app/models/custom/verification/residence.rb`:
|
For example for Madrid's City Hall fork its required to check the zip code's format (it always starts with 280 followed by 2 digits). That check is at `app/models/custom/verification/residence.rb`:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
require_dependency Rails.root.join('app', 'models', 'verification', 'residence').to_s
|
load Rails.root.join("app", "models", "verification", "residence.rb")
|
||||||
|
|
||||||
class Verification::Residence
|
class Verification::Residence
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
En el caso de los componentes, la personalización puede utilizarse para cambiar tanto la lógica (incluida en un archivo `.rb`) como la vista (incluida en un archivo `.erb`). Si solo quieres personalizar la lógica, por ejemplo del componente `Admin::TableActionsComponent`, crea el archivo `app/components/custom/admin/table_actions_component.rb` con el siguiente contenido:
|
En el caso de los componentes, la personalización puede utilizarse para cambiar tanto la lógica (incluida en un archivo `.rb`) como la vista (incluida en un archivo `.erb`). Si solo quieres personalizar la lógica, por ejemplo del componente `Admin::TableActionsComponent`, crea el archivo `app/components/custom/admin/table_actions_component.rb` con el siguiente contenido:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
require_dependency Rails.root.join("app", "components", "admin", "table_actions_component").to_s
|
load Rails.root.join("app", "components", "admin", "table_actions_component.rb")
|
||||||
|
|
||||||
class Admin::TableActionsComponent
|
class Admin::TableActionsComponent
|
||||||
# Tu lógica personalizada aquí
|
# Tu lógica personalizada aquí
|
||||||
@@ -15,7 +15,7 @@ Si, por el contrario, también quieres personalizar la vista, necesitas una pequ
|
|||||||
```ruby
|
```ruby
|
||||||
class Admin::TableActionsComponent < ApplicationComponent; end
|
class Admin::TableActionsComponent < ApplicationComponent; end
|
||||||
|
|
||||||
require_dependency Rails.root.join("app", "components", "admin", "table_actions_component").to_s
|
load Rails.root.join("app", "components", "admin", "table_actions_component.rb")
|
||||||
|
|
||||||
class Admin::TableActionsComponent
|
class Admin::TableActionsComponent
|
||||||
# Tu lógica personalizada aquí
|
# Tu lógica personalizada aquí
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ Si quieres agregar modelos nuevos, o modificar o agregar métodos a uno ya exist
|
|||||||
Por ejemplo en el caso del Ayuntamiento de Madrid se requiere comprobar que el código postal durante la verificación sigue un cierto formato (empieza con 280). Esto se realiza creando este fichero en `app/models/custom/verification/residence.rb`:
|
Por ejemplo en el caso del Ayuntamiento de Madrid se requiere comprobar que el código postal durante la verificación sigue un cierto formato (empieza con 280). Esto se realiza creando este fichero en `app/models/custom/verification/residence.rb`:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
require_dependency Rails.root.join('app', 'models', 'verification', 'residence').to_s
|
load Rails.root.join("app", "models", "verification", "residence.rb")
|
||||||
|
|
||||||
class Verification::Residence
|
class Verification::Residence
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user