Skip to content

Commit 720e3eb

Browse files
committed
Added rough-pass documentation
1 parent b5a83b4 commit 720e3eb

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

docs/guide/configuration.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,33 @@ Inertia Rails supports setting any configuration option via environment variable
4444

4545
Use `component_path_resolver` to customize component path resolution when [`default_render`](#default_render) config value is set to `true`. The value should be callable and will receive the `path` and `action` parameters, returning a string component path. See [Automatically determine component name](/guide/responses#automatically-determine-component-name).
4646

47+
### `prop_transformer`
48+
49+
**Default**: `->(props:) { props }`
50+
51+
Use `prop_transformer` to apply a transformation to your props before they're sent to the view. One use-case this enables is to work with `snake_case` props within Rails while working with `camelCase` in your view:
52+
53+
```ruby
54+
inertia_config(
55+
prop_transformer: lambda do |props:|
56+
props.deep_transform_keys { |key| key.to_s.camelize(:lower) }
57+
end
58+
)
59+
```
60+
61+
> [!NOTE]
62+
> This controls the props provided by Inertia Rails but does not concern itself with props coming _into_ Rails. You may want to add a global `before_action` to `ApplicationController`:
63+
64+
```ruby
65+
before_action :underscore_params
66+
67+
# ...
68+
69+
def underscore_params
70+
params.deep_transform_keys! { |key| key.to_s.underscore }
71+
end
72+
```
73+
4774
### `deep_merge_shared_data`
4875

4976
**Default**: `false`

0 commit comments

Comments
 (0)