I have an indentation problem in my Coffee Script!!
I'm asking myself how put these lines of code so that they run smoothly and don't skip stuff. The impact is that the array friendsCollection is empty, when I want to use it in my view.
I guess the problem is coffee script (javascript) itself (because it works asynchronously) but I have no idea how to go about that.
Now, this is the code:
app.get '/', (req, res) ->
  brain = req.session
  if brain.userId
    friendsCollection = []
    data.serialize ->
      data.each "select rowid as id, * from friends where userId='#{brain.userId}'", (err, row) ->
        if not err
          if row isnt undefined
            friend =
              name: row.name
              email: row.email
              phone: row.phone
              location: row.location
              relationship: row.relationship
              notes: row.notes
            friendsCollection.push friend
      res.render 'app/index',
        id: brain.userId
        friendsCollection: friendsCollection
  else
    res.render 'notAllowed'
I would be happy if someone could fix this code (a little bit)!
