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

Use view_helpers of the controller instance instead of standalone module #45

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/hotwire/spark/middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def call(env)
status, headers, response = @app.call(env)

if html_response?(headers)
@request = ActionDispatch::Request.new(env)
html = html_from(response)
html = inject_javascript(html)
html = inject_options(html)
Expand Down Expand Up @@ -38,7 +39,7 @@ def script_tag
end

def view_helpers
ActionController::Base.helpers
@request.controller_instance.helpers
end

def inject_options(html)
Expand Down
2 changes: 2 additions & 0 deletions test/dummy/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ class Application < Rails::Application
#
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")

config.asset_host = ->(asset, request) { "#{request.host}:#{request.port}" }
end
end
Loading