HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
rails-api
active_model_serializers
Ruby2013–2017
rails-api / active_model_serializers

active_model_serializers

ActiveModel::Serializer implementation and Rails hooks

8Distinct people
12Mentions
1Explicit recommenders
5.3KGitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

ActiveModel::Serializer implementation and Rails hooks

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

I came here to say the exact same thing. After having worked on/scaled an API that served >100k requests per minute, I feel I can say with some experience that defining your…

jerhinesmith used a recommendation phrase. One indexed comment matches. This is a phrase match, not a verdict.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 1:49:46 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year12 dated mentions

Observed mentions: 2013-02-05 04:54:54 UTC to 2017-01-05 03:57:02 UTC.

024682013-01-01 00:00:00 UTC to 2014-01-01 00:00:00 UTC (exclusive): 8 mentions; 0 submissions, 8 comments20132014-01-01 00:00:00 UTC to 2015-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2015-01-01 00:00:00 UTC to 2016-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments20152016-01-01 00:00:00 UTC to 2017-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2017-01-01 00:00:00 UTC to 2018-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2017

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20132013-01-01 00:00:00 UTC2014-01-01 00:00:00 UTC808
20142014-01-01 00:00:00 UTC2015-01-01 00:00:00 UTC202
20152015-01-01 00:00:00 UTC2016-01-01 00:00:00 UTC000
20162016-01-01 00:00:00 UTC2017-01-01 00:00:00 UTC101
20172017-01-01 00:00:00 UTC2018-01-01 00:00:00 UTC101

What Hacker News says

12 sources
to handle it without every service having a database connection to every other service's datastore you end up with something like a conversion step from Magic Model Object to a PORO, and that sucks wind. I actually prefer the distinction: serialized domain objects do not have access to the full richness of the ORM API, so having a separate class representing the specific behavior of an API-wrapper makes a lot more sense to me. Something like ActiveModel::Serializers wraps up a lot of the boilerplate while also letting you retrieve nested object graphs in a single request: https://github.com/rails-api/active_model_serializers That said at Square we generally use protobuf-based RPC for our service-to-service requests, because we have a polyglot SOA so it's important for our services to produce and consume protos to support more languages th
Read the rest
an just Ruby.
In Rails has won: The Elephant in the Room
jerhinesmith·Jul 28, 2014Recommendation phrase
I came here to say the exact same thing. After having worked on/scaled an API that served >100k requests per minute, I feel I can say with some experience that defining your JSON in your model is a very bad idea. A classic example that we ran into repeatedly: Assume you want to have an endpoint that populates a user's profile (for the user to see). You probably want id, name, email, age, location, created_at, updated_at, etc. However, when exposing this same user instance through an endpoint that publicly aggregates users (e.g. search), sending over all those fields is 1) overkill, and 2) raises privacy concerns. So far, my favorite approach to this problem uses the ActiveModel::Serializer gem (https://github.com/rails-api/active_model_serializers). It moves the JSON logic to something more akin to a view, and provides an easy way to p
Read the rest
resent instances differently depending on the context.
In FastAPI – Easily create robust, standardized API endpoints in Rails and Postgres
Rails-api is a gem that configures rails in a more lean and mean fashion for API usage, it doesn't handle the json serialization. Mostly rails-api disables a lot of default rails features/middlewares that aren't needed when you're only building an API. For json serialization you may want to look at Active Model Serializers[0], I found it much easier to work with than rabl, and it's also written by the rails-api group. [0] https://github.com/rails-api/active_model_serializers
In How to Wire Up Ruby on Rails and AngularJS as a Single-Page Application
Sorry you guys had trouble with Ember Data. Our first conception of Ember Data was that it would act as an ORM on top of JSON, and the architecture would allow developers to build adapters for many different kinds of backends. Unfortunately, there is no JSON analog to SQL. Every existing backend forms their JSON differently, especially when you start modeling relationships. It would be like trying to build ActiveRecord if every team rolled their own query language for each new project. We're trying to make this better in the long-term with projects like http://jsonapi.org, and https://github.com/rails-api/active_model_serializers for Rails. We'll get there someday. In the meantime, we totally rebooted the Ember Data project to make it simple for people to customize how their apps consume JSON APIs. Most people we've talked to have been ve
Read the rest
ry happy about the fact that the defaults are simple to override now, and how much simpler the internals have become. We have a small amount of work left to do before we declare a 1.0 final; in the meantime, we've cut a 1.0 beta build that you can get from http://emberjs.com/builds.
In What's Coming in Ember.js in 2014
Thanks for the suggestion! In fact, you've just described exactly what we're building. We are big fans of REST, and if you read the documentation, you'll see that the default behavior of Ember Data is to transmit RESTful JSON[1]. In addition, we've been working with a bunch of really smart Rails people like Steve Klabnik and Santiago Pastorino on projects like ActiveModel::Serializers[2] and rails-api[3]. That being said, we know that there are a lot of different ways to serialize and transmit records, so we've designed the architecture of Ember Data such that those decisions are encapsulated in specific objects which we call adapters. You can think of it like the adapters for different databases for ORMs like ActiveRecord. The default adapter, though, is RESTful JSON, and is what we use in all of our applications. You can see the impleme
Read the rest
In Stabilizing Ember Data
ActiveModel::Serializers maintainer here. We've been working closely with Discourse (which is currently running edge AMS) to make sure we have the easiest and best way to get data from your Ruby web framework into shape so that it's easily consumed by any JS framework, not just Ember. It's important to get all of this stuff right: the seam in the middle is where your SPA talks to the back-end, and provides the ability to, for example, have two different teams work on each side without worrying as much about the format, or possibly even writing a new back-end without affecting the client side. Feedback and comments very welcome: https://github.com/rails-api/active_model_serializers/issues... for bugs and https://groups.google.com/forum/#!forum/rails-api-core for feature requests and discussion.
In Why we're moving away from Ember.js
That's def a job for the adapters. Django, for instance, has a REST adapter that has been worked on here: https://github.com/toranb/ember-data-django-rest-adapter As far as the root objects are concerned, I've always been a fan of that part of Rails. Not to say that it cannot be easily gotten rid of with something like this (for ActiveResource)... ActiveResource::Base.include_root_in_json = false Or, like in my example app, with this (for ActiveModelSerializers)... https://github.com/rails-api/active_model_serializers#1-disa...
In EmberJS Confuses Me
ember-data is a completely separate project that is still under heavy development. You can use ember without touching ember-data, and unless you are on the happy path of Rails with the active_model_serializers[0] gem, I would recommend not using ember-data. You can roll your own light-weight layer, and Ember's object system will give you lots of rich functionality. There is also ember-resource[1] and ember-rest[2] if you want something a little less hand-crafted. [0]: https://github.com/rails-api/active_model_serializers [1]: https://github.com/zendesk/ember-resource [2]: https://github.com/cerebris/ember-rest
In Ember.js 1.0 RC1 released

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.