render_turbo_stream 1.4.10 → 1.4.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -4
- data/lib/render_turbo_stream/version.rb +1 -1
- data/lib/render_turbo_stream.rb +4 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 344d9c5276c13acd3cbde921821be8d224befaca25d1492af766c45cb80f7993
|
4
|
+
data.tar.gz: b7a86cd99b8d5808590c5ed14032f8275c3ae284e90e9682c5b4c2b8dcec332e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee892284af2df779af7051f5e8c3f8132595657997429b1ba0d6a8585460a5ed087620c1c5182a786fe5a96c56f6968fc9c192db826f95a00b76a2d6d3ca14a7
|
7
|
+
data.tar.gz: b74f6487ea7f28a854b98d088e547b80ab67cfb2bbfd1bb62dab24d9d36f2f6b78a42b7e1e78f95ff8c91930632a87fd37a3f3a9d8275b2a418b8a650931435e
|
data/README.md
CHANGED
@@ -48,7 +48,7 @@ config.x.render_turbo_stream.flash_id = 'flash-box'
|
|
48
48
|
config.x.render_turbo_stream.flash_action = 'prepend'
|
49
49
|
```
|
50
50
|
|
51
|
-
The corresponding partials for flashes could look [like this](https://gitlab.com/sedl/renderturbostream/-/wikis/
|
51
|
+
The corresponding partials for flashes could look [like this](https://gitlab.com/sedl/renderturbostream/-/wikis/Flashes-example)
|
52
52
|
|
53
53
|
**Translations**
|
54
54
|
|
@@ -142,13 +142,12 @@ Under the hood, inside a `*.turbo_stream.erb` template, it does the following: `
|
|
142
142
|
|
143
143
|
**WORKAROUND for redirects inside frame**
|
144
144
|
|
145
|
-
Suppose you have a CRUD controller that should do all its actions inside a turbo frame. Classic redirect_to,
|
145
|
+
Suppose you have a CRUD controller that should do all its actions inside a turbo frame. Classic redirect_to, together with a turbo_stream action on the same response, would raise «Render and/or redirect were called multiple times in this action». See [issue](https://gitlab.com/sedl/renderturbostream/-/issues/3).
|
146
146
|
|
147
|
-
|
147
|
+
A workaround is to use the src attribute of the parent frame. `turbo_frame_set_src` comes from turbo_power. The code could look like this:
|
148
148
|
|
149
149
|
```ruby
|
150
150
|
def update
|
151
|
-
@car = Car.find(params['id'])
|
152
151
|
turbo_stream_save(
|
153
152
|
@car.update(car_params),
|
154
153
|
streams_on_success: [
|
data/lib/render_turbo_stream.rb
CHANGED
@@ -160,9 +160,10 @@ module RenderTurboStream
|
|
160
160
|
ary = []
|
161
161
|
array.each do |pr|
|
162
162
|
if !pr.present?
|
163
|
-
|
163
|
+
Rails.logger.warn " WARNING render_turbo_stream: Empty element inside attributes: «#{array}»"
|
164
164
|
elsif pr.is_a?(Hash)
|
165
165
|
props = pr.symbolize_keys
|
166
|
+
raise "missing attribute :id in #{props}" if !props[:id].present?
|
166
167
|
part = (props[:partial].present? ? props[:partial] : props[:id]).gsub('-', '_')
|
167
168
|
partial = (part.to_s.include?('/') ? part : [controller_path, part].join('/'))
|
168
169
|
r = props
|
@@ -170,6 +171,7 @@ module RenderTurboStream
|
|
170
171
|
r[:partial] = partial
|
171
172
|
ary.push(r)
|
172
173
|
elsif pr.is_a?(Array)
|
174
|
+
raise "array has to contain at least one element: #{pr}" unless pr.first.present?
|
173
175
|
ary.push(pr)
|
174
176
|
else
|
175
177
|
raise "ERROR render_turbo_stream invalid type: Only hash or array allowed"
|
@@ -289,7 +291,7 @@ module RenderTurboStream
|
|
289
291
|
:append,
|
290
292
|
:prepend
|
291
293
|
]
|
292
|
-
(config.present? ? config : default).map{|m|m.to_sym}.include?(method.to_sym)
|
294
|
+
(config.present? ? config : default).map { |m| m.to_sym }.include?(method.to_sym)
|
293
295
|
end
|
294
296
|
|
295
297
|
end
|