User Tools

Site Tools


ruby

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
ruby [2026/03/14 16:47] reddyruby [2026/03/15 19:56] (current) reddy
Line 73: Line 73:
 rm storage/development.sqlite db/schema.rb rm storage/development.sqlite db/schema.rb
 rails db:drop db:create db:migrate rails db:drop db:create db:migrate
 +</code>
 +
 +==== Turbo Frames ====
 +
 +Turbo frames are for partial view updates. When the view is being rendered, return content within the turbo frame tag with the same identifier. domid(model_object) can be used to generate an identifier.
 +
 +<code>
 +# In home/index view
 +<%= turbo_frame_tag "str_1" do %>
 +This is a thing
 +<%= link_to 'Action', controller: 'home', action: 'info'
 +<% end %>
 +
 +# In home/info view
 +<%= turbo_frame_tag "str_1" do %>
 +This is another thing
 +<%= link_to 'Action', controller: 'home', action: 'index'
 +<% end %>
 +
 +</code>
 +
 +==== Turbo Streams ====
 +
 +<code>
 +# In the view
 +<%= turbo_stream_from "src_1" %>
 +<div id="divvy_1"></div>
 +
 +# In a controller
 +Turbo::StreamsChannel.broadcast_update_to(
 +  'src_1',
 +  target: 'divvy_1',
 +  content: DateTime.now  # html: render ...
 +)
 </code> </code>
  
ruby.1773503236.txt.gz · Last modified: by reddy

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki