Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reinitialize controller_class renderer with connection.env #481

Merged
merged 1 commit into from
Apr 5, 2021

Conversation

leastbad
Copy link
Contributor

@leastbad leastbad commented Mar 28, 2021

Type of PR (feature, enhancement, bug fix, etc.)

Bug fix

Description

Assuming people use the render method, this initializes the mock controller renderer instance with the connection.env.

We should update the docs to say that if people use ArbitraryController.render then they should actually use ArbitraryController.renderer.new(connection.env).render instead.

Why should this be added

Should prevent "session bleed".

Testing

# app/helpers/home_helper.rb
module HomeHelper
  def shitblast
    "yummy"
  end
end
<div class="card-body d-flex justify-content-center">
  <div id="test"></div>
  <button class="btn btn-dark" type="button" data-reflex="click->Example#renderer">Test</button>
</div>
<%# app/views/home/_test.html.erb %>
<%= current_user.name %><br>
<%= shitblast %><br>
<%= home_path %><br>
<%= render partial: "home/test2" %>
<%# app/views/home/_test2.html.erb %>
Yowza!
<%= current_user.name %><br>
<%= shitblast %><br>
<%= home_path %><br>
class ExampleReflex < ApplicationReflex
  def renderer
    morph "#test", render(partial: "home/test")
  end
end

Checklist

  • My code follows the style guidelines of this project
  • Checks (StandardRB & Prettier-Standard) are passing
  • This is not a documentation update

@leastbad leastbad merged commit 80f2381 into stimulusreflex:master Apr 5, 2021
@leastbad leastbad deleted the renderer branch August 16, 2021 03:16
marcoroth pushed a commit to marcoroth/stimulus_reflex that referenced this pull request Oct 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants