FriendlyId 5 Support #892

wants to merge 1 commit into

6 participants


Quick Fix until a better solution is provided


You should probably rescue NoMethodError instead of a blanket rescue.

Also, does cancan claim to support friendlyid? I'm not sure cancan will want to include your self-confessed "nasty hack" just to support another library, even one as popular as friendly_id.

You might consider writing an adapter gem, eg. cancan-friendly_id, which would re-open CanCan::ModelAdapters::AbstractAdapter and overwrite find.

Honestly, cancan is so busy trying to get support for strong_parameters out the door that it doesn't seem to be accepting new features anyway. So, an adapter gem is probably a better way to get your idea published.


This needed in my application. Thanks


According to the friendly_id documentation, you can re-enable the overloading of "find" like so:

friendly_id :foo, use: [:slugged, :finders] # you can now do MyClass.find('bar')

I was able to use this to restore compatibility between the two libraries without modifying cancan.


Super! Thanks for that info, I will definitely use that technique.


@jaredbeck sorry for the very late reply. You are right, there's a better way however via @andrewculver comment. I will definitely take your advise next time I contribute, I honestly understand you.



Glad to hear you guys found a workaround. Please close this issue. Thanks!


Yep! Closing curtains. Cheers!

@nukturnal nukturnal closed this Sep 17, 2013

Dropping a note here, even if the issue has already been closed. You can also use

load_and_authorize_resource find_by: :slug

That will work without overriding the finder.


load_and_authorize_resource find_by: :slug
unfortunately doesnt seem to work with rails 4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment