Skip to content

render_component fails when controller returns 304 #4

@elado

Description

@elado

When my controller returns 304 result, the render_component fails with this error:

undefined method `redirect_url' for []:Array

on this line:

response = component_response(options, true)[2]

** if response.redirect_url **
  redirect_to response.redirect_url
else
  render :text => response.body, :status => response.status
end

The reason is because controller.dispatch(action, request) returns an array with:

[304, {"ETag"=>"....", "Cache-Control"=>"max-age=0, private, must-revalidate"}, []]

instead of the 200 result which looks like:

[200, {"Content-Type"=>"text/html; charset=utf-8", "ETag"=>"\"...\"", "Cache-Control"=>"max-age=0, private, must-revalidate }, #<ActionDispatch::Response:0x007f8eee1918b8 @writer=...

Tried to add request_env["Cache-Control"] = "no-store, no-cache, must-revalidate" as a header but no luck.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions