Skip to content

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

Closed
amiel opened this Issue May 18, 2011 · 5 comments

4 participants

@amiel
amiel commented May 18, 2011

I just discovered that load_and_authorize_resource calls find on the model at https://github.com/ryanb/cancan/blob/master/lib/cancan/controller_resource.rb#L103, 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?

@emmanuel

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.

@maxsum-corin

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?

@maxsum-corin

Ok made pull request now: #376

What do you think?

@maxsum-corin

Just noticed this is a dup of #373

@maxsum-corin

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.