render_turbo_stream 4.3.9 → 4.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1632f986315bf12186e902f24959cd243b541ba1cf6055e88d53ea2019564855
|
4
|
+
data.tar.gz: 398cbcba033712aab8d7bf1022b40c5c47cb55820026e11387db4aa5d53c137f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2d46b22f8505bc1c6a5b7cd1c388e848dc90a7353e6cf86cfdb3c9a776bedd85be3f01cc25349b99b784d3aadbb682a8f23dc70d0a8a861db02131a6b1950d3
|
7
|
+
data.tar.gz: 73bec9e074afbf69bcd3765fd8100cb6721897bd70dd2d9488f079bf0daf39f2c54feb7f8cc881bbd45b4eddb7678d86cce767bfab583c53a92b97bc41ee3ae1
|
data/README.md
CHANGED
@@ -193,6 +193,7 @@ The target ID for turbo has to be unique for sure, and it has to be nice, becaus
|
|
193
193
|
```ruby
|
194
194
|
# target_id(virtual_view_path, object)
|
195
195
|
target_id('customers/_form', Customer.new) #=> 'new-customer-form'
|
196
|
+
target_id('form', Customer.new) #=> 'new-customer-form'
|
196
197
|
```
|
197
198
|
|
198
199
|
View-helper: Assuming we are inside `customers/_my_form`:
|
@@ -206,7 +207,8 @@ target_id(Customer.first) #=> 'customer-1-my-form'
|
|
206
207
|
target_id( [Customer.first, Article.last, 'hello'] ) #=> 'customer-1-article-7-hello-my-form'
|
207
208
|
target_id('hi-joe') #=> 'hi-joe'
|
208
209
|
|
209
|
-
target_id_css('hi-joe') #=> '#hi-joe'
|
210
|
+
target_id_css('hi-joe') #=> '#hi-joe'
|
211
|
+
#=> is available for system tests, example for capybara: «within target_id_css('articles/_form', @article) do ..
|
210
212
|
```
|
211
213
|
|
212
214
|
Why include the filename in a html-id? Because for turbo its likely to have multiple cases for the same object on the same page, for example: _form, _show, _password. These can all be the same customer.
|
@@ -238,6 +240,10 @@ In order to avoid this kind of tedious coding, the gem has a kind of fallback bu
|
|
238
240
|
3. If all that not is found it raises a exception
|
239
241
|
4. wraps the partial within the `turbo_stream.*` and sends this to the front.
|
240
242
|
|
243
|
+
**Debugging**
|
244
|
+
|
245
|
+
If a save action fails, `turbo_stream_save` and `turbo_channel_save` are logging the output from `Model.errors.full_messages` to the console, at log-level `:debug`.
|
246
|
+
|
241
247
|
# Request Testing
|
242
248
|
|
243
249
|
To test if the whole system works together, including javascript actions, so that finally a part reaches the surface, there is **Capybara** system testing. But it is a good practice to **break tests into smaller pieces**. So, there are helpers for **enabling the much faster request tests that are much easier to maintain**.
|
@@ -183,6 +183,10 @@ module RenderTurboStream
|
|
183
183
|
raise libs.action_errors(turbo_actions).join(', ')
|
184
184
|
end
|
185
185
|
|
186
|
+
unless save_action
|
187
|
+
RenderTurboStream::Libs.debug_save_errors(object, flash_controller_action_name)
|
188
|
+
end
|
189
|
+
|
186
190
|
# xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
187
191
|
#== RENDER TO CHANNEL
|
188
192
|
# xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
@@ -197,7 +201,7 @@ module RenderTurboStream
|
|
197
201
|
end
|
198
202
|
|
199
203
|
if save_action && if_success_redirect_to.present?
|
200
|
-
response.status =
|
204
|
+
response.status = 303
|
201
205
|
redirect_to if_success_redirect_to
|
202
206
|
end
|
203
207
|
|
@@ -67,6 +67,7 @@ module RenderTurboStream
|
|
67
67
|
|
68
68
|
unless save_action
|
69
69
|
response.status = 422
|
70
|
+
RenderTurboStream::Libs.debug_save_errors(object, flash_controller_action_name)
|
70
71
|
end
|
71
72
|
|
72
73
|
# xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
@@ -76,7 +77,7 @@ module RenderTurboStream
|
|
76
77
|
allow_channel = (Rails.configuration.x.render_turbo_stream.allow_channel_to_me_for_turbo_stream_save rescue false) && (helpers.current_user.id.present? rescue false)
|
77
78
|
|
78
79
|
if save_action && if_success_turbo_redirect_to.present?
|
79
|
-
response.status =
|
80
|
+
response.status = 303
|
80
81
|
flash[:alert] = flashes[:alerts]
|
81
82
|
flash[:notice] = flashes[:notices]
|
82
83
|
Rails.logger.debug(" • Successful saved && Redirect by «turbo_redirect_to»")
|
@@ -84,5 +84,16 @@ module RenderTurboStream
|
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
|
+
def self.debug_save_errors(object, controller_action_name)
|
88
|
+
if object.id.present?
|
89
|
+
Rails.logger.debug(" • #{controller_action_name} #{object.class}:#{object.id} FAILED:")
|
90
|
+
else
|
91
|
+
Rails.logger.debug(" • #{controller_action_name} #{object.class} FAILED:")
|
92
|
+
end
|
93
|
+
object.errors.full_messages.each do |e|
|
94
|
+
Rails.logger.debug(" => #{e}")
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
87
98
|
end
|
88
99
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: render_turbo_stream
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.3.
|
4
|
+
version: 4.3.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- christian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|