You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/components/action.md
+27Lines changed: 27 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,6 +62,33 @@ success: {
62
62
}
63
63
```
64
64
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
+
classTestModelsController < ApplicationController
80
+
includeMatestack::Ui::Core::ApplicationHelper
81
+
82
+
defcreate
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
+
65
92
### Failure
66
93
67
94
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