Access File ID in Middleman-Dato

I’m using the middleman-dato gem. How can I get the ID of a file? When I run .to_hash on a file (say, dato.my_model.my_file.to_hash), I get only the following properties:

:format=>"mp4",
:size=>3053305,
:width=>100,
:height=>100,
:alt=>nil,
:title=>nil,
:custom_data=>{},
:url=>"https://www.datocms-assets.com/12809/1564129785-water.mp4"

I’m aware the GraphQL API provides this and is much more powerful overall (I’m using it for many other projects), but for my current project a simple Middleman site is the best fit.

you are right! We need to add the id to the hash. I’m going to do that soon, not sure if today, but surely by tomorrow!

1 Like

@webworkshop sorry yesterday has been a bit frantic… BUT, I’ve just released our dato gem version 0.7.8 which should expose the upload id.

Can you please update and check if that does what you expect? Thank you!

1 Like

This works perfectly, thank you!

It’s great to see Dato keeping things up to date for the Ruby + Middleman setup. Middleman can seem a bit dead when you look at Github activity (and Ruby front-end packages in general), but I think there are a lot of people quietly hacking away on these kinds of sites.

1 Like

Yes I agree. We have many loyal middleman users on DatoCMS. Often it just works, so we update it whenever things like this happens, but if there’s not much movement sometimes is because it does what it’s supposed to! :slight_smile: