Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
backbone model woes
#OUTPUT
undefined
Currentuser {attributes: Object, _escapedAttributes: Object, cid: "c1", changed: Object, _silent: Object…}
_changing: false
_escapedAttributes: Object
_pending: Object
_previousAttributes: Object
_silent: Object
attributes: Object
_id: "50bcd700dbc554a9a8000003"
email: "patrickjholloway@me.com"
font_ids: Array[0]
style_ids: Array[0]
username: null
__proto__: Object
changed: Object
cid: "c1"
__proto__: ctor
#VIEW
class Workshop.Views.FontsIndex extends Backbone.View
el: '#content_wrapper'
initialize: ->
current_user = new Workshop.Models.Currentuser
current_user.fetch()
console.log(current_user.id)
#MODELS
# I'm trying to get the current user id to a Workshop.Models.User model so I can save the user to the database through the Rails users RESTful resource. I can't retrieve the id from the Currentuser model. ?
class Workshop.Models.Currentuser extends Backbone.Model
idAttribute: '_id'
urlRoot: -> '/user/currentuser/'
class Workshop.Models.User extends Backbone.Model
urlRoot: '/users/show'
#COLLECTION
# I am pretty sure I am doing my model and collection completely wrong. There are mapping to a standard rails resource CRUD controller/routes
class Workshop.Collections.Users extends Backbone.Collection
model: Workshop.Models.User,
url: '/users'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.