Created
September 8, 2021 07:39
-
-
Save skyporter/d078f36ea8c82af92613616686553ec2 to your computer and use it in GitHub Desktop.
Rails render view outside controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FakeController < ActionController::Base | |
include ApplicationHelper | |
def current_user | |
@current_user ||= User.find(params[:user_id]) | |
end | |
end | |
renderer = FakeController.renderer.new( | |
'action_dispatch.request.path_parameters' => { | |
user_id: 4685 | |
} | |
) | |
renderer.render(file: 'shared/events/index.pdf.erb', layout: "layouts/pdf", assigns: {events: Event.where(id: 463385), organization: Organization.find(42)}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment