Prefer templates for turbo streams in all but the very simplest cases
(And probably even then)
This commit is contained in:
@@ -3,18 +3,10 @@ class Collections::PublicationsController < ApplicationController
|
||||
|
||||
def create
|
||||
@collection.publish
|
||||
render turbo_stream: [
|
||||
turbo_stream.replace([ @collection, :publication ], partial: "collections/edit/publication", locals: { collection: @collection }),
|
||||
turbo_stream_flash(notice: "Saved")
|
||||
]
|
||||
end
|
||||
|
||||
def destroy
|
||||
@collection.unpublish
|
||||
@collection.reload
|
||||
render turbo_stream: [
|
||||
turbo_stream.replace([ @collection, :publication ], partial: "collections/edit/publication", locals: { collection: @collection }),
|
||||
turbo_stream_flash(notice: "Saved")
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
module TurboFlash
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
helper_method :turbo_stream_flash
|
||||
end
|
||||
|
||||
private
|
||||
def turbo_stream_flash(**flash_options)
|
||||
turbo_stream.replace(:flash, partial: "layouts/shared/flash", locals: { flash: flash_options })
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
<%= turbo_stream.replace([ @collection, :publication ], partial: "collections/edit/publication", locals: { collection: @collection }) %>
|
||||
<%= turbo_stream_flash(notice: "Saved") %>
|
||||
@@ -0,0 +1,2 @@
|
||||
<%= turbo_stream.replace([ @collection, :publication ], partial: "collections/edit/publication", locals: { collection: @collection }) %>
|
||||
<%= turbo_stream_flash(notice: "Saved") %>
|
||||
Reference in New Issue
Block a user