Using ActiveStorage in Rails API-apps
28-Mar-2019 1730
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 #Using #ActiveStorage #Rails #API-apps #activestorage #api-apps https://rubyonrails.ba/link/using-activestorage-in-rails-api-apps