lukejagodzinski / meteor-astronomy-sort-behavior

https://atmospherejs.com/jagi/astronomy-sort-behavior
MIT License
2 stars 1 forks source link

update failed: Access denied #3

Open JulianKingman opened 8 years ago

JulianKingman commented 8 years ago

I get this error when using the sort methods. Do I need to set allow rules or run it in a method?

lukejagodzinski commented 8 years ago

Show the sample code

JulianKingman commented 8 years ago
Fragment = Astro.Class({
    name: 'Fragment',
    collection: Fragments,
    fields: {
        //skipping irrelevant fields
        source: {
            type: 'array',
            default: function(){return [];}
        }
    },
    behaviors: {
        timestamp: {},
        sort: {
            orderFieldName: 'sortOrder',
            hasRootField: true,
            rootFieldName: 'source'
        }
    }
//skipping irrelevent methods
}

And then the template event:

'click .nextFragment': function () {
        Session.get('currentFragment').moveUp();
        Session.set('currentFragment', Fragments.findOne({sortOrder: 0}));
    }
JulianKingman commented 8 years ago

note: also tried moveToBottom() and all the other sort methods, same error.

With template.onRendered, 'currentFragment' is set like this: Session.set('currentFragment', Fragments.findOne({sortOrder: 0}));

Hmm... I'm not specifying the source field in the Session variable, so it could be sorting the wrong list. Let me try that, let me know if you see any other issues, in the meantime.

lukejagodzinski commented 8 years ago

You probably have deny rules on the Fragments collection that disallow such update

JulianKingman commented 8 years ago

No deny rules in the whole app. Any other things that could cause that?

lukejagodzinski commented 8 years ago

Log to the console what is inside Session.get('currentFragment') and post here. It's hard to tell without investigation.

JulianKingman commented 8 years ago

It looks like this:

{
  "_modifiers": {},
  "_references": {},
  "_id": "ijZzJyf6WhHB3zxqu",
  "createdAt": null,
  "updatedAt": null,
  "sortOrder": 0,
  "source": [
    "dH9an2iWmccgJ3csx"
  ],
  "text": "Text fragment",
  "dateSearched": null,
  "dateStarted": null,
  "depthSearched": 0,
  "depthDescription": null,
  "status": "Ready",
  "searchedBy": null,
  "locked": null,
  "useSource": false,
  "links": [],
  "_isNew": false
}
JulianKingman commented 8 years ago

Astronomy methods seem to work on it (like Session.get('currentFragment').raw())

lukejagodzinski commented 8 years ago

You will have to create reproduction repository. It's probably not astronomy fault. I will take a look at reproduction when I'm back from vacations.