Skip to content

Instantly share code, notes, and snippets.

@tobobo
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save tobobo/0d42ee5477cc1d94283f to your computer and use it in GitHub Desktop.

Select an option

Save tobobo/0d42ee5477cc1d94283f to your computer and use it in GitHub Desktop.
Authentication = DS.Model.extend
user_id: DS.attr 'number'
facebook_id: DS.attr 'string'
facebook_updated: DS.attr 'date'
user: DS.belongsTo 'user'
`export default Authentication`
User = DS.Model.extend
email: DS.attr 'string'
password: DS.attr 'string'
reach: DS.attr 'number'
picture: DS.attr 'string'
name: DS.attr 'string'
authentication: DS.belongsTo 'authentication'
displayName: (->
@get('name') or @get('email')
).property 'email', 'name'
`export default User`
{
"user": {
"id": 3,
"email": "[email protected]",
"password": "$2a$10Fej09Aj0FKpEJV3/Nx8XHV6tM/J.aM6la",
"picture": null,
"created_at": "2014-06-11T19:39:00.496Z",
"updated_at": "2014-06-11T19:39:00.588Z",
"reach": 250,
"name": null,
"authentication": {
"id": 3,
"user_id": 3,
"facebook_id": "12345",
"facebook_access_token": "blah blah",
"facebook_refresh_token": null,
"facebook_updated": "2014-06-11T07:00:00.000Z",
"stripe_customer_id": null,
"stripe_card_token": null,
"created_at": null,
"updated_at": null
}
}
}
UserSerializer = DS.RESTSerializer.extend DS.EmbeddedRecordsMixin,
keyForAttribute: (attr) -> attr
attrs:
authentication:
embedded: 'always'
`export default UserSerializer`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment