runemadsen/cancan-backbone

Why can't subject have a class?

Closed this issue · 3 comments

I am not sure I understand the check to see if a subject has a class on line 132. It is causing issues when I am trying to filter out some models by id. The rule has an array of ids under the conditions. When I remove this code from line 132:

&& !this.subject_class(subject)

it works and doesn't show the models that are not in the list.

Hi @colleenbprice

Can you try to post a code example that doesn't work, or better, a failing test? Then I can try to help you out.

I was dealing with some code not written by me and they were defining the model as this:

var Post = Backbone.Model.extend({
  backboneClass: 'Post'
  ...
});

instead of
var Post = Backbone.Model.extend({
...
},{backboneClass: 'Post'});

Not sure I understand it completely, but when I changed the model to the second format, it started working. I discovered this when I was trying to write a test like you requested and saw that you were declaring it that way.

👍