Skip to content

Instantly share code, notes, and snippets.

@swanson
Last active September 28, 2020 23:30
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swanson/c7f4097d187384064da6704b03f1bf53 to your computer and use it in GitHub Desktop.
Save swanson/c7f4097d187384064da6704b03f1bf53 to your computer and use it in GitHub Desktop.
:plain
var existingModal = document.querySelector("[data-controller='modal']");
if (existingModal) {
document.body.removeChild(existingModal);
}
document.body.insertAdjacentHTML("beforeend", "#{j render partial: template.to_s, locals: local_assigns }");
class FooController < ApplicationController
def edit
render :as_modal, locals: { template: :form }
end
def update
if @model.update(model_params)
redirect_to @model, notice: "Success!"
else
render :as_modal, locals: { template: :form }
end
end
...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment