NoMethodError: private method `open' called for #<URI::Generic:0x000055d4f2e16f00>

Viewed 1286

NoMethodError: private method `open' called for # (Most recent call first) File /app/app/interactors/order/store_purchases.rb line 55 in store_purchase

store_purchase:

...

purchase.capture.attach(io: URI.parse(context.capture).open, filename: context.capture)
...

This error on only on heroku deploy... What I did wrong? Help me please

2 Answers

URI#open is private on older Ruby versions, for example 2.2. You need to use a different method (such as the global open provided by open-uri, though this is questionable from the security standpoint) on those Rubies. Or use a newer Ruby version.

Related