I have a class that is not an ActiveRecord object and im trying to create a AM serializer for it. I can return the proper json, but its not including a root
in have this in my controller
format.json { render json: @current_user, root: "current_user" }
and my class looks like this
class CurrentUser
include ActiveModel::Validations
include ActiveModel::Conversion
extend ActiveModel::Naming
attr_accessor :first_name, :last_name, :user_type, :user_id
end
Ive also tried adding this in the controller
def default_serializer_options
{root: true}
end
But still my json object does not have the root which I need for Ember Model
return object
{"first_name":"Luke","last_name":"Skywalker","user_type":"Padawan","user_id":12}
and I need
{current_user: {"first_name":"Luke","last_name":"Skywalker","user_type":"Padawan","user_id":12} }