Installation
This guide covers the installation process for Ruby JSONAPI.
Requirements
- Ruby 2.5 or later
- Rails 5.0+ (for Rails integration features)
Standard Installation
Add this line to your application’s Gemfile:
gem 'ruby_jsonapi'
Then execute:
$ bundle install
Or install it yourself with:
$ gem install ruby_jsonapi
Rails Integration
Ruby JSONAPI includes Rails integration features like generators. When used with Rails, the gem is automatically configured and ready to use.
Generators
To generate a serializer for a model, use the Rails generator:
$ rails g serializer Movie name year director_id box_office
This will create:
# app/serializers/movie_serializer.rb
class MovieSerializer
include JSONAPI::Serializer
attributes :name, :year, :director_id, :box_office
end
Manual Configuration
If you’re not using Rails, you’ll need to require the gem manually:
require 'jsonapi/serializer'
Next Steps
Once you have installed Ruby JSONAPI, proceed to the Basic Serialization guide to learn how to use the library.