Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Except & Always methods #1

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions docs/guide/partial-reloads.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ router.visit(url, {

## Except certain props

> [!WARNING]
> The `except` option is not yet supported by the Inertia Rails.
:::tabs key:frameworks
== Vue 2

Expand Down Expand Up @@ -215,6 +212,18 @@ class UsersController < ApplicationController
end
```

On the inverse, you can use the `InertiaRails.always` method to specify that a prop should always be included, even if it has not been explicitly required in a partial reload.

```ruby
class UsersController < ApplicationController
def index
render inertia: 'Users/Index', props: {
users: InertiaRails.always(User.all),
}
end
end
```

Here's a summary of each approach:

```ruby
Expand All @@ -235,6 +244,11 @@ class UsersController < ApplicationController
# OPTIONALLY included on partial reloads
# ONLY evaluated when needed
users: InertiaRails.lazy(-> { User.all }),

# ALWAYS included on standard visits
# ALWAYS included on partial reloads
# ALWAYS evaluated
users: InertiaRails.always(User.all),
}
end
end
Expand Down
Loading