Rails API (JSON)

Hi, I have an API that delivers data throught JSON format. But, the JSON is built using JBuilder GEM. Perhaps that Ember uses a specifc JSON format.

How can I make my API works with Ember ? The last option would be change the API code to use ActiveModel::Serializer.

Thanks.

You don’t need to use AMS. Just write your jbuilder responses to return data in the expected format:

# If embedding
json.posts(@posts) do |post|
  json.extract!(post, :id, :body, :comment_ids)
end
json.comments(@comments) do |comment|
  json.extract!(comment, :id, :body)
end

# If not embedding
json.posts(@posts) do |post|
  json.extract!(post, :id, :body)
  json.links do
    json.comments post_comments_url(post)
  end
end