Using ActiveStorage in Rails API-apps

Rails 5.2 introduced ActiveStorage as one of its main features. Using it from Rails views is easy and well-documented - but how can you use it in a Rails API-app?In this short tutorial, you will learn how to use and test ActiveStorage in a Rails API-only app. While the integration of ActiveStorage into Rails is mainly very good, there are some pitfalls to consider.We will create a simple user model, consisting of a username and an attached avatar, and write a controller to create a user and download its avatar. We will use the command-line tool curl and the testing framework RSpec to test this controller. In the progress, we will discover two shortcomings of ActiveStorage and will show how to circumvent them.
Using ActiveStorage in Rails API-apps #ruby #rubydeveloper #rubyonrails #activestorage #api-apps https://rubyonrails.ba/single/using-activestorage-in-rails-api-apps

Nezir Zahirovic

Contractor Ruby On Rails (8+ years) / MCPD .Net / C# / Asp.Net / CSS / SQL / (11 years)

related articles