Skip to content

load_and_authorize_resource calls `find` on DataMapper instead of `get` #373

amiel opened this Issue May 18, 2011 · 5 comments

4 participants

amiel commented May 18, 2011

I just discovered that load_and_authorize_resource calls find on the model at, but DataMapper models should be called with get instead of find.

I just forked @emmanuel's fork with the intention of fixing this right away, but I'm not sure what the best way to implement this would be. I'm guessing you probably don't want datamapper specific logic in CanCan::ControllerResource.

Suggestions on how to implement this?


I think the best fix here might be to add model_adapter#find to the model_adapter interface, but that might be too invasive. It definitely looks like loading doesn't currently work without providing a (roughly) AR::Base#find-compatible interface.


Hi, I just discovered this myself... cancan is getting an Enumerator over all objects in the database from Class(Enumerable)#find.

I'd like to see this maxsum-corin@c849a1d, but I'm not making a pull request because this would break the current usage of :find_by... maybe a new option, :finder, might be appropriate?


Ok made pull request now: #376

What do you think?


Just noticed this is a dup of #373


Ok this seems to be working, but now my nested resources don't :( returns all)

@ryanb ryanb closed this in 613ab1c May 21, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.