I have a page that I want to display different groups of users on. So far I am filtering the groups in the UsersController (ArrayController) with the following.
users_controller.js.coffee:
App.UsersController = Ember.ArrayController.extend
content: []
group1: (->
@get('model').filterProperty('role', "group1")
).property('model.@each.type')
group2: (->
@get('model').filterProperty('role', "group2")
).property('model.@each.type')
group3: (->
@get('model').filterProperty('role', "group3")
).property('model.@each.type')
I am able to loop through each group in my users template with the following (using Emblem.js).
users.emblem
.role
h3 Group 1
each user in group1
.segment
= link-to 'user' user | #{user.first} #{user.last}
p
span #{user.shortStory}
.role
h3 Group 2
= each user in group2
.segment
= link-to 'user' user | #{user.first} #{user.last}
p
span #{user.shortStory}
.role
h3 Group 3
= each user in group3
.segment
= link-to 'user' user | #{user.first} #{user.last}
p
span #{user.shortStory}
Each user has a 'story' in its model. On the UserController I have a method called shortStory that shortens it into a 100 character or so snippet. (see the following code)
user_controller.js.coffee
App.UserController = Ember.ObjectController.extend
shortStory: (->
short = @get('story').substring(0, 100)
for i in short by - 1
if i == " "
break
else
short = short.slice( 0, -1)
short
).property('story')
My problem is that I cannot get the shortStory to display for any of the users. I have tried many different syntaxes including the following:
span= user.shortStory
span #{user.shortStory}
span= shortStory
span= #{user.shortStory}
If anyone knows how I can access the UserController method while looping through a UsersController filter method in the view that would be great.
I am also open to other suggestions for filtering the data in the first place. I am still pretty fresh to ember.