Skip to content

Commit 3ae8c8c

Browse files
committed
Docs: improve searchability by naming methods
1 parent 483c6bf commit 3ae8c8c

10 files changed

+50
-20
lines changed

docs/guide/asset-versioning.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ One common challenge when building single-page apps is refreshing site assets wh
44

55
## Configuration
66

7-
To enable automatic asset refreshing, you need to tell Inertia the current version of your assets. This can be any arbitrary string (letters, numbers, or a file hash), as long as it changes when your assets have been updated.
7+
To enable automatic asset refreshing, you need to tell Inertia the current version of your assets using the `InertiaRails.configure` method and setting the `config.version` property. This can be any arbitrary string (letters, numbers, or a file hash), as long as it changes when your assets have been updated.
88

99
```ruby
1010
InertiaRails.configure do |config|

docs/guide/client-side-setup.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ npm install @inertiajs/svelte svelte
3232

3333
## Initialize the Inertia app
3434

35-
Next, update your main JavaScript file to boot your Inertia app. To accomplish this, we'll initialize the client-side framework with the base Inertia component.
35+
Next, update your main JavaScript file to boot your Inertia app. To accomplish this, we'll use the `createInertiaApp` function to initialize the client-side framework with the base Inertia component.
3636

3737
:::tabs key:frameworks
3838
== Vue

docs/guide/configuration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Inertia Rails can be configured globally or in a specific controller (and subcla
44

55
## Global Configuration
66

7-
If using global configuration, we recommend you place the code inside an initializer:
7+
Use the `InertiaRails.configure` method to set global configuration options. If using global configuration, we recommend you place the code inside an initializer:
88

99
```ruby
1010
# config/initializers/inertia.rb
@@ -19,7 +19,7 @@ The default configuration can be found [here](https://github.com/inertiajs/inert
1919

2020
## Local Configuration
2121

22-
Use `inertia_config` in your controllers to override global settings:
22+
The `inertia_config` method allows you to override global settings in specific controllers. Use this method in your controllers to customize configuration for specific parts of your application:
2323

2424
```ruby
2525
class EventsController < ApplicationController

docs/guide/csrf-protection.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Inertia's Rails adapter automatically includes the proper CSRF token when making requests via Inertia or Axios. Therefore, **no additional configuration is required**.
66

7-
However, if you need to handle CSRF protection manually, one approach is to include the CSRF token as a prop on every response. You can then use the token when making Inertia requests.
7+
However, if you need to handle CSRF protection manually, one approach is to include the CSRF token as a prop on every response. You can then use the token when making Inertia requests with the `router.post` method.
88

99
:::tabs key:frameworks
1010
== Vue
@@ -67,7 +67,7 @@ When a CSRF token mismatch occurs, Rails raises the `ActionController::InvalidAu
6767

6868
Obviously, this isn't a great user experience. A better way to handle these errors is to return a redirect back to the previous page, along with a flash message that the page expired. This will result in a valid Inertia response with the flash message available as a prop which you can then display to the user. Of course, you'll need to share your [flash messages](/guide/shared-data.md#flash-messages) with Inertia for this to work.
6969

70-
You may modify your application's exception handler to automatically redirect the user back to the page they were previously on while flashing a message to the session. To accomplish this, you may use the `rescue_from` method in your `ApplicationController`.
70+
You may modify your application's exception handler to automatically redirect the user back to the page they were previously on while flashing a message to the session. To accomplish this, you may use the `rescue_from` method in your `ApplicationController` to handle the `ActionController::InvalidAuthenticityToken` exception.
7171

7272
```ruby
7373
class ApplicationController < ActionController::Base

docs/guide/deferred-props.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Inertia's deferred props feature allows you to defer the loading of certain page
44

55
## Server side
66

7-
To defer a prop, you can use the defer method when returning your response. This method receives a callback that returns the prop data. The callback will be executed in a separate request after the initial page render.
7+
To defer a prop, you can use the `InertiaRails.defer` method when returning your response. This method receives a callback that returns the prop data. The callback will be executed in a separate request after the initial page render.
88

99
```ruby
1010
class UsersController < ApplicationController
@@ -20,7 +20,7 @@ end
2020

2121
### Grouping requests
2222

23-
By default, all deferred props get fetched in one request after the initial page is rendered, but you can choose to fetch data in parallel by grouping props together.
23+
By default, all deferred props get fetched in one request after the initial page is rendered, but you can choose to fetch data in parallel by grouping props together using the `group` option with the `InertiaRails.defer` method.
2424

2525
```ruby
2626
class UsersController < ApplicationController

docs/guide/forms.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ For a full discussion on handling and displaying [validation](/guide/validation.
186186

187187
## Form helper
188188

189-
Since working with forms is so common, Inertia includes a form helper designed to help reduce the amount of boilerplate code needed for handling typical form submissions.
189+
Since working with forms is so common, Inertia includes a form helper designed to help reduce the amount of boilerplate code needed for handling typical form submissions. The `useForm` method provides a convenient way to manage form state, validation, and submission.
190190

191191
:::tabs key:frameworks
192192
== Vue

docs/guide/history-encryption.md

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Imagine a scenario where your user is authenticated, browses privileged informat
66

77
When you instruct Inertia to encrypt your app's history, it uses the browser's built-in [`crypto` api](https://developer.mozilla.org/en-US/docs/Web/API/Crypto) to encrypt the current page's data before pushing it to the history state. We store the corresponding key in the browser's session storage. When the user navigates back to a page, we decrypt the data using the key stored in the session storage.
88

9-
Once you instruct Inertia to clear your history state, we simply clear the existing key from session storage roll a new one. If we attempt to decrypt the history state with the new key, it will fail an Inertia will make a fresh request back to your server for the page data.
9+
Once you instruct Inertia to clear your history state, we simply clear the existing key from session storage and roll out a new one. If we attempt to decrypt the history state with the new key, it will fail and Inertia will make a fresh request back to your server for the page data.
1010

1111
> [!NOTE]
1212
> History encryption relies on `window.crypto.subtle` which is only available in secure environments (sites with SSL enabled).
@@ -47,12 +47,41 @@ end
4747

4848
## Clearing history
4949

50-
To clear the history state, you can pass the `clear_history` option to the `render` method:
50+
To clear the history state on the server side, you can pass the `clear_history` option to the `render` method:
5151

5252
```ruby
5353
render inertia: 'Dashboard', props: {}, clear_history: true
5454
```
5555

5656
Once the response has rendered on the client, the encryption key will be rotated, rendering the previous history state unreadable.
5757

58-
You can also clear history on the client site by calling `router.clearHistory()`.
58+
### Client-side clearing
59+
60+
You can also clear history directly on the client side by calling the `router.clearHistory()` method:
61+
62+
:::tabs key:frameworks
63+
== Vue
64+
65+
```js
66+
import { router } from '@inertiajs/vue3'
67+
68+
router.clearHistory()
69+
```
70+
71+
== React
72+
73+
```js
74+
import { router } from '@inertiajs/react'
75+
76+
router.clearHistory()
77+
```
78+
79+
== Svelte 4|Svelte 5
80+
81+
```js
82+
import { router } from '@inertiajs/svelte'
83+
84+
router.clearHistory()
85+
```
86+
87+
:::

docs/guide/manual-visits.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,15 +270,14 @@ router.post('/users', {
270270
== Svelte 4|Svelte 5
271271

272272
```js
273-
274-
```
275-
276273
import { router } from '@inertiajs/svelte'
277274

278275
router.post('/users', {
279-
name: 'John Doe',
280-
276+
name: 'John Doe',
277+
281278
})
279+
```
280+
282281
:::
283282

284283
## Custom headers

docs/guide/responses.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ Inertia Rails provides a number of generators to help you get started with Inert
139139

140140
### Scaffold generator
141141

142-
To create a resource with Inertia responses, execute the following command in the terminal:
142+
Use the `inertia:scaffold` generator to create a resource with Inertia responses. Execute the following command in the terminal:
143143

144144
```bash
145145
bin/rails generate inertia:scaffold ModelName field1:type field2:type
@@ -185,7 +185,7 @@ Inertia Rails tries to detect the presence of Tailwind CSS in the application an
185185

186186
### Controller generator
187187

188-
To create a controller with an Inertia response, execute the following command in the terminal:
188+
Use the `inertia:controller` generator to create a controller with an Inertia response. Execute the following command in the terminal:
189189

190190
```bash
191191
bin/rails generate inertia:controller ControllerName action1 action2
@@ -211,7 +211,7 @@ $ bin/rails generate inertia:controller pages welcome next_steps
211211

212212
### Customizing the generator templates
213213

214-
Rails generators allow templates customization. For example, to customize the controller generator view template, create a file `lib/templates/inertia_templates/controller/react/view.jsx.tt`:
214+
Rails generators allow templates customization. You can create custom template files in your application to override the default templates used by the generators. For example, to customize the controller generator view template for React, create a file at the path `lib/templates/inertia_templates/controller/react/view.jsx.tt`:
215215

216216
```jsx
217217
export default function <%= @action.camelize %>() {

docs/guide/testing.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ end
3535

3636
### Assertions
3737

38+
Inertia Rails provides several RSpec matchers for testing Inertia responses. You can use methods like `expect_inertia`, `render_component`, `have_exact_props`, `include_props`, `have_exact_view_data`, and `include_view_data` to test your Inertia responses.
39+
3840
```ruby
3941
# spec/requests/events_spec.rb
4042
RSpec.describe '/events', inertia: true do

0 commit comments

Comments
 (0)