Q:

Firebase .push() throws 'permission_denied' error

When creating entering new data with .push(), like so:
var passes = chatRef.push('passes');
    passes.set({
      userID: FirebaseRef.user.id, 
      gymName: $(this.options.data.gymName.getContent()).text().split(/[ ]+/).join(' '), 
      price: $(this.options.data.price.getContent()).text().split(/[ ]+/).join(' '),
      numDays: window.gymDays
    })

I get the following alert from Firebase:
FIREBASE WARNING: set at /-JPBDARJ67cnr6Yr_nGZ failed: permission_denied
My Security Rules:
{
  "rules": {
    "users": {
      ".write": true,
      "$userid": {
        ".read": "auth.id == $userid",
        ".write": true
      }
    },
    "passes": {
     ".write": true
    }
  }
}

Any idea how to fix?

A:

The problem here occurs when you call var passes = chatRef.push('passes');. You're actually creating a new child at this point, not just accessing the child "passes". Your security rules allow you to write to "passes", but they aren't allowing you to create "passes".
To solve the problem, get rid of the line var passes = chatRef.push('passes'); and replace it with var passes = chatRef.child('passes');. That way, it will be accessing a child in Firebase, not creating one.
EDIT:
For adding children, use .push():
passes.push({
  userID: FirebaseRef.user.id, 
  gymName: $(this.options.data.gymName.getContent()).text().split(/[ ]+/).join(' '), 
  price: $(this.options.data.price.getContent()).text().split(/[ ]+/).join(' '),
  numDays: window.gymDays
});

