Coder Social home page Coder Social logo

Comments (5)

fabrik42 avatar fabrik42 commented on June 21, 2024

Hi Kai,

I see your problem and I will take care of it this week. This is also a feature I want, so I can make acts_as_api compatible with backbone.js out of the box. :)

from acts_as_api.

fabrik42 avatar fabrik42 commented on June 21, 2024

Btw: I've chosen another default response format as the Rails 3 default response format is imho not consistent, when it comes to render sub resources:

While rails wraps a collection of models in a root node by default

{ users: [ { user: { name: "tina" } },  { user: { name: "tina" } } ] }

It doesn't do this for included associations, e.g.

[
    {
        "user": {
            "created_at": "2011-04-26T08: 43: 10Z",
            "updated_at": "2011-04-26T08: 43: 10Z",
            "id": 1,
            "tasks": [
                {
                    "created_at": "2011-04-26T08: 44: 22Z",
                    "completed": false,
                    "updated_at": "2011-04-26T08: 44: 22Z",
                    "id": 2,
                    "user_id": 1,
                    "description": "Be a Jedi"
                },
                {
                    "created_at": "2011-04-26T08: 44: 30Z",
                    "completed": false,
                    "updated_at": "2011-04-26T08: 44: 30Z",
                    "id": 3,
                    "user_id": 1,
                    "description": "Destroy Deathstar"
                }
                ...
            ],
            "last_name": "Skywalker",
            "first_name": "Luke"
        }
    },
    ...
]

But I will add a config option to restore the default Rails behaviour. :)

from acts_as_api.

fabrik42 avatar fabrik42 commented on June 21, 2024

Hi Kai,

just add

ActsAsApi::Config.include_root_in_json_collections = true

in your initializers and the response should look like the Rails 3 response.

from acts_as_api.

medihack avatar medihack commented on June 21, 2024

Hi Christian, you are right with those inconsistencies in the Rails output. That's why we decided to use the more consistent way of your ActsAsApi default representation in upcoming projects. Thanks again for the great support.

from acts_as_api.

fabrik42 avatar fabrik42 commented on June 21, 2024

You're welcome! :)

from acts_as_api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.