Skip to content

Commit 4ce90bc

Browse files
committed
Fix Rails 8.1 inline locals and frozen template rendering
1 parent 474d393 commit 4ce90bc

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

app/helpers/cubism_helper.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ def cubicle_for(resource, user, scope: "", html_options: {}, appear_trigger: :co
99
location: block_location,
1010
view_context: self
1111
)
12+
if block_source.variable_name.blank?
13+
block_variable_name = block.parameters.find { |type, _| [:req, :opt, :rest].include?(type) }&.last
14+
if block_variable_name.present?
15+
block_source.variable_name = block_variable_name.to_s
16+
Cubism.source_store[block_source.digest] = block_source
17+
end
18+
end
1219

1320
resource_gid = resource.to_gid.to_s
1421

lib/cubism/broadcaster.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ def broadcast
2121

2222
block_source = block_container.block_source
2323

24-
html = ApplicationController.render(inline: block_source.source, locals: {"#{block_source.variable_name}": present_users})
24+
inline_source = block_source.source
25+
inline_source = inline_source.dup if inline_source.frozen?
26+
html = ApplicationController.render(inline: inline_source, locals: {"#{block_source.variable_name}": present_users})
2527

2628
selector = "cubicle-element#cubicle-#{element_id}[identifier='#{signed_stream_identifier(resource.to_global_id.to_s)}']"
2729

0 commit comments

Comments
 (0)