> Please, have a look at the documentation. The :no_attribute_check option for
> filter_resource_access should help.
Actually, I don't think this helps. The problem isn't in the
controller action, it is in the model check. I can trigger it in the
rails console apart from the controller.
I've made some addtions to the demo app at git://
github.com/dgm/decl_auth_demo_app.git
I've added a Address model that is joined through ConferenceAddress.
It's a bit contrived, but it illustrates the problem.
Using the rules provided, an admin can create an address by:
address = Conference.find(conference_id).addresses.create
(new does not create the join table reference)
(build lets me make the object, but then I cannot save it for the same
reasons)
This sets up a ConferenceAddress object and an Address object in the
Conference.addresses collection. But when you try to do the same
thing as a user role, it fails. I suspect the problem is that create
() makes the Address object first, then the ConferenceAddress object,
since it needs an identifier to point to the right address object.
However, declarative_authorization does the permission check
immediately upon creation of the Address object, before the
ConferenceAddress object has ben initialized.
I'm not sure right now how to fix this - the permission check needs to
be delayed a bit.
As far as models go, couldn't the create action be checked on save?
It seems like it would be plausible that the permission couldn't be
checked until all the data conditions are in place....