We've moved discussions to Discord

Administrate and User model doesnt allow changing the find_resource

Alex Deering
Im using a public_uid string for lookup on my models. Everything works great for one model, but for the User model I get this error:
NoMethodError in Admin::UsersController#show
undefined method `find_by_public_uid' for Admin::User:Module
Here is my override in the Admin user controller
def find_resource(param)
   User.find_by_public_uid(param)
end
On another note whenever I try to regenerate the administrate dashboard for the user model I get an error unless I comment out this line:
include UserAgreements, UserTeams 
This is the offending part of the stack trace for that
/home/dring/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/bundler/gems/administrate-aa1df6d8b294/lib/generators/administrate/dashboard/dashboard_generator.rb:127:in `association_type': undefined method `has_one?' for nil:NilClass (NoMethodError)

Chris Oliver
Your error said it was trying to use Admin::User, not the global User, so I'd guess that's the problem. Try making your override use the global User class.

def find_resource(param)
  ::User.find_by_public_uid(param)
end

I'm still hoping that we get some time to finish Madmin so we can ditch Administrate.
Alex Deering
That did the trick, you rock.  

Whats Madmin?
Chris Oliver
It's a new admin UI for Rails that myself, Jason Charnes, and Andrew Fomera started working on. We haven't had much time to work on it though. 
Alex Deering
That would be nice, administrate started out nice but has definitely gotten more bloated over the years
Notifications
You’re not receiving notifications from this thread.