saving blob data to a file

I have an binary field in my database where i am storing images uploaded by the user.

Now I need to fetch all these images from the database and store them in file system.

Do Ruby provide method to write a blob data into a file system.

ruby file access: