datocms / middleman-dato

A Middleman extension to integrate your website with DatoCMS
https://docs.datocms.com/middleman/overview.html
MIT License
24 stars 7 forks source link

Imgix domain error when using Middleman 5 #12

Closed danhalliday closed 4 years ago

danhalliday commented 4 years ago

I get the following error when calling the url method on an image while using middleman-data with the Middleman 5 release candidate:

ArgumentError at /.../template.html
The :domain option must be specified

/Users/dan/.rvm/gems/ruby-2.7.1/gems/imgix-4.0.0/lib/imgix/client.rb: in validate_domain!
      raise ArgumentError, domain_error if @domain.nil?...
/Users/dan/.rvm/gems/ruby-2.7.1/gems/imgix-4.0.0/lib/imgix/client.rb: in initialize
      validate_domain!...
/Users/dan/.rvm/gems/ruby-2.7.1/gems/dato-0.7.13/lib/dato/local/field_type/file.rb: in new
          Imgix::Client.new(...
/Users/dan/.rvm/gems/ruby-2.7.1/gems/dato-0.7.13/lib/dato/local/field_type/file.rb: in file
          Imgix::Client.new(...
/Users/dan/.rvm/gems/ruby-2.7.1/gems/dato-0.7.13/lib/dato/local/field_type/file.rb: in url
          file.to_url(opts)...
/Users/dan/.../template.html.erb: in block in __tilt_85600
      <%= image_tag image.url(w: 300, fm: :jpg), alt: image.alt %>

I'm using the latest gems:

source "https://rubygems.org"

gem "rake"

gem "middleman", git: "https://github.com/middleman/middleman", tag: "v5.0.0.rc.1"
gem "middleman-livereload", "~> 3.4"
gem "middleman-dato", "~> 0.9.0"

gem "dato", "~> 0.7.13"

Any ideas what I could tweak to get this gem working with Middleman 5? I guess the Imgix code in the data gem isn’t getting initialised properly.

danhalliday commented 4 years ago

Got it — this is due to the latest Imgix gem’s use of a domain argument for Imgix::Client.new, which the dato gem doesn’t pass in. It doesn’t actually look like it’s anything to do with Middleman 5 or middleman-dato. The version of the Imgix gem in dato probably needs an upper version constraint. Here’s my fixed Gemfile with the downgraded Imgix gem:

source "https://rubygems.org"

gem "rake"

gem "middleman", git: "https://github.com/middleman/middleman", tag: "v5.0.0.rc.1"
gem "middleman-livereload", "~> 3.4"
gem "middleman-dato", "~> 0.9.0"

gem "dato", "~> 0.7.13"
gem "imgix", "~> 0.3.1"
stefanoverna commented 4 years ago

Thanks, working on it!

matjack1 commented 4 years ago

hey @danhalliday we've released version 0.7.14 of our gem that should solve the issue.

I'm closing here, but feel free to reopen if it's not fixed!