Questions tagged [active-model-serializers]

The purpose of `ActiveModel::Serializers` is to provide an object to encapsulate serialization of `ActiveModel` objects, including `ActiveRecord` objects.

Purpose

The purpose of ActiveModel::Serializers is to provide an object to encapsulate serialization of ActiveModel objects, including ActiveRecord objects.

Serializers know about both a model and the current_user, so you can customize serialization based upon whether a user is authorized to see the content.

In short, serializers replaces hash-driven development with object-oriented development.

Documentation

See the github project's README

739 questions
-1
votes
1 answer

Unrelated rspec tests fail after adding active_model_serializers

I'm super confused. I think I'm encountering some kind of bug. Could use some help. I had passing specs (passed dozens of times on local and CI server), and these were completely unrelated to serializers. Like they _just check the status of certain…
-1
votes
1 answer

active model serializers rails json doesnt work inside another json object

iam using active model serializers in my rails, this is my snippet # GET /users def index @users = User.all render json: {data: @users, status: httpstatus[:getSuccess]} # render json: {data: @users, status: httpstatus[:getSuccess]} …
cahyowhy
  • 553
  • 2
  • 9
  • 26
-1
votes
3 answers

How to change the project default Time format in Rails

Before I updated Rails, the default Time format the API was returning was yyyy-MM-dd'T'HH:mm:ss'Z'. Now it returns yyyy-MM-dd'T'HH:mm:ss:sss'Z'. I want to change it back due to apps that rely on the old time format. How can I change this PROJECT…
Andy
  • 10,553
  • 21
  • 75
  • 125
-1
votes
1 answer

ruby/rails variable scope before assignment

UPDATE: Thanks guys, went with this: def add_minor if @user.minors.count <= 2 render :json => @user.profile.minors << Minor.find(params[:minor_id]), :status => 200 else render :json => '', :status => 409 end end is there a better…
errata
  • 23,596
  • 2
  • 22
  • 32
1 2 3
49
50