Closed fabn closed 8 years ago
Greate!
It could be useful in some cases to disable friendly_id. But as for me this behaviour could be easily and nicely implemented like, for example, separated gem and should not be a part of core functionality.
@fabn are you still using the code sample u gave here? is it working well?
@jtomaszewski that project was dismissed some time ago, but that code worked well in production on a high traffic website with no issues for more than one year.
Just keep in mind that it was a Rails 4.2.x project running AA 1.0.0.pre, however since the code is pretty simple it should work also in other versions.
@fabn Above code worked well in rails 4 But recently I had to update the rails to 7.0.3 and ruby 2.7.2 and I am getting this error:
ActiveAdmin::BaseController.include is throwing .rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/activeadmin-2.13.1/lib/active_admin/base_controller/authorization.rb:3:in `module:ActiveAdmin': uninitialized constant InheritedResources::Base (NameError)
because of the line ActiveAdmin::BaseController.include(ActiveAdmin::FriendlyIdDisabler)
I've added FriendlyId to an existing project which uses ActiveAdmin for backend and I encountered lot of errors in my test suite (I'm using
scoped
module). I already saw other issues (e.g. #526 and #653) and while some of them can be solved by overriding AAfind_resource
scoping issues can't be solved.Also in admin interfaces one may want to retain url with id instead of slugs for debugging purposes.
Finally I have lot of code and since I'm lazy I don't want to rewrite all of it :-)
For these reason I wrote a small monkeypatch to disable FriendlyId in active admin code. Here's it:
In the model:
And finally activate it in ActiveAdmin with this code:
Now I have two questions:
disabler
module that provides the described behavior. Do you think it's useful?