-
Notifications
You must be signed in to change notification settings - Fork 39
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
Support custom 'Content-Disposition' options #40
Support custom 'Content-Disposition' options #40
Conversation
lib/prawn-rails/rails_helper.rb
Outdated
options = get_prawn_options | ||
|
||
# Don't override the 'Content-Disposition' if we've chosen to set it elsewhere. | ||
controller.response.headers['Content-Disposition'] ||= "#{options[:disposition]}; filename=\"#{options[:filename]}\"" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ||=
was the biggest pain point we had - we set our own Content-Disposition
s in our controllers, and having the gem totally scrap those was frustrating!
ab76ecb
to
03b4847
Compare
@westonganger I've updated this to be |
README.md
Outdated
end | ||
``` | ||
|
||
This uses the [`Content-Disposition` HTTP header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition#As_a_response_header_for_the_main_body). If you've already set this header, `prawn-rails` will *not* override it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you maybe show an example usage/assignment of this header?
Thanks! Could you also update the changelog? |
…prawn-rails into custom-content-disposition
@westonganger Updated. I bumped to 1.3.x since this could break someone using the old renderer with |
Merged! Thanks for your contribution! |
Resolves #33 by allowing much more detailed control of the
Content-Disposition
header generated byprawn-rails
:@filename
ivar (preserves current functionality).@filename
set, use the:filename
and:disposition
option keys on theprawn_document
helper.Content-Disposition=inline;
)Also: updated tests & README.