Skip to content
This repository has been archived by the owner on Jun 10, 2018. It is now read-only.

Nested model? #53

Open
netwire88 opened this issue Jul 17, 2012 · 2 comments
Open

Nested model? #53

netwire88 opened this issue Jul 17, 2012 · 2 comments

Comments

@netwire88
Copy link

Hi,
I'm a eco newbie and I'm trying to integrate it with Backbone. I checked out Ryan Bates' RailsCast example. However, I'm having trouble accessing a simple get.

I can do this: <%= @stream.get('stream_type') %> which returns "project"
But how do I get user.name? I tried <%= @stream.user.get('name') %> but I got error: Uncaught TypeError: Cannot call method 'get' of undefined

[
: {
: : "id":"5004095283de4ca9ff000005",
: : "stream_type":"project",
: : "user":
: : {
: : : "id":"5002f30560de7d0ffb000003",
: : : "name":"Regular User2"
: : },

@jonathangordon
Copy link

If user is a Backbone model, then you should use @stream.get('user').get('name'). You need to use get() to access the user attribute, and user is a Backbone model.

@mbhnyc
Copy link

mbhnyc commented Aug 27, 2013

The best way to debug issues like this is to insert either a breakpoint in your compiled template in chrome/firebug, or a debugger statement in the code, which chrome/firebug will detect and pause output. Then you can just check "this" in the debugger and fiddle until you find the right reference.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants