Comments (5)
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.
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.
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.
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.
You're welcome! :)
from acts_as_api.
Related Issues (20)
- Rails 5: undefined method `as_api_response' for ActiveRecord_Associations_CollectionProxy HOT 18
- NoMethodError render_for_api with rails 5 api app HOT 7
- DEPRECATION WARNING: Initialization autoloaded the constants ActionText::ContentHelper and ActionText::TagHelper.
- Dynamic template name in extend is not supported. HOT 1
- No options found for Remove functionality. not supporting if condition HOT 1
- InvalidURIError while deploying to heroku
- Rails 3 Responder: undefined method `list_url' HOT 1
- Ruby 2.0, Rails Mongoid, and NoMethodError (undefined method `empty?' for nil:NilClass) HOT 1
- Active Model support HOT 1
- Using class methods in api_accessible definition HOT 1
- Json with all Root nodes HOT 4
- new feature HOT 4
- respond_with not working with after_filter HOT 3
- Does not use model_name when using this without ORM HOT 3
- Parent Name under association HOT 3
- can't modify frozen Hash representing deleted AR objects HOT 1
- DateTime objects are truncating milliseconds HOT 5
- introduction: confuse links
- can i have json without root element? HOT 8
- Completely custom Json output HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from acts_as_api.