Skip to content

Commit ca12ec1

Browse files
committed
documenting follow_response option for action component
#288
1 parent 59eb32b commit ca12ec1

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

docs/components/action.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,33 @@ success: {
6262
}
6363
```
6464

65+
When the server redirects to a url, for example after creating a new record, the transition needs to be configured to follow this redirect of the server response.
66+
67+
```ruby
68+
success: {
69+
emit: 'my_action_success',
70+
transition: {
71+
follow_response: true
72+
}
73+
}
74+
```
75+
76+
A controller action that would create a record and then respond with the url the page should transition to, could look like this:
77+
78+
```ruby
79+
class TestModelsController < ApplicationController
80+
include Matestack::Ui::Core::ApplicationHelper
81+
82+
def create
83+
@test_model = TestModel.create(test_model_params)
84+
85+
render json: {
86+
transition_to: test_model_path(@test_model)
87+
}, status: :ok
88+
end
89+
end
90+
```
91+
6592
### Failure
6693

6794
As counterpart to the success part of the action component, there is also the possibility to define the failure behavior. This is what gets triggered after the response to our action returns a failure code, usually in the range of `400` or `500` HTTP status codes.

0 commit comments

Comments
 (0)