You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there. Some colleagues and I were working with wicked_pdf and wkhtmltopdf-heroku when we noticed an issue. The latter gem adds a new value to WickedPdf.config[:exe_path] but the app was not getting it. Turns out our initializer overwrites the whole hash by doing WickedPdf.config = { ... }. I noticed the README says this is the recommended way to set config.
Of course the fix is simple enough but I wonder if something similar has happened to other devs. IMHO, there's a better way to set config by using a config block pattern:
# inside config/initializers/wicked_pdf.rbWickedPdf.configuredo |config|
config[:page_size]="Letter"end# inside any other gem:WickedPdf.configuredo |config|
config[:exe_path]=CUSTOM_EXE_PATHend
This way config is never completely overwritten, only specific keys, and values from other gems can be preserved and combined. We can also have default values if we need them.
What do you all think about this? I could implement this myself if you all feel this would be useful. We can still support WickedPdf.config = and even add a deprecation warning for it.
The text was updated successfully, but these errors were encountered:
This sounds like a good idea. I remember looking into it years ago, but it was never a priority. I would like to maintain backwards compatibility though.
Hi there. Some colleagues and I were working with
wicked_pdf
andwkhtmltopdf-heroku
when we noticed an issue. The latter gem adds a new value toWickedPdf.config[:exe_path]
but the app was not getting it. Turns out our initializer overwrites the whole hash by doingWickedPdf.config = { ... }
. I noticed the README says this is the recommended way to setconfig
.Of course the fix is simple enough but I wonder if something similar has happened to other devs. IMHO, there's a better way to set
config
by using a config block pattern:This way
config
is never completely overwritten, only specific keys, and values from other gems can be preserved and combined. We can also have default values if we need them.What do you all think about this? I could implement this myself if you all feel this would be useful. We can still support
WickedPdf.config =
and even add a deprecation warning for it.The text was updated successfully, but these errors were encountered: