We've moved discussions to Discord

Crash when Show user in the Admin dashboard

NG DAVID
I would like to impersonate another user.  When I click on the user on the user list, it crashes with the following message when user has avatar image  with the following message


NameError in Admin::Users#show

Showing /home/david/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/bundler/gems/administrate-66c6d333106b/app/views/fields/has_one/_show.html.erb where line #22 raised:
uninitialized constant AvatarAttachmentDashboard

It is OK if the user does not have avatar.  What is wrong ? 


Same here!
Dan Weaver
There's another post about this somewhere here. If you just want to get it working comment out all the `Avatar` lines in the `app/dashboards/user_dashboard.rb` file
Dan Weaver
require "administrate/base_dashboard"

class UserDashboard < Administrate::BaseDashboard

  ATTRIBUTE_TYPES = {
    id: Field::Number,
    ...
    # avatar_attachment: Field::HasOne, # <============= COMMENT THIS OUT
    # avatar_blob: Field::HasOne, # <=================== COMMENT THIS OUT
    ...
  }.freeze

  # SHOW_PAGE_ATTRIBUTES
  # an array of attributes that will be displayed on the model's show page.
  SHOW_PAGE_ATTRIBUTES = [
    :id,
    ...
    # :avatar_attachment, # <======================== COMMENT THIS OUT
    # :avatar_blob, # <============================== COMMENT THIS OUT
    ...
  ].freeze

end


Dan Weaver
Not had time to look into a proper fix for this yet but I don't care about seeing the user's image in the admin dashboard so I just removed the attributes and left it at that 😀
Chris Oliver
I just published a fix for this. I've added ActiveStorage support to the admin (using this) so the avatars are now set as activestorage fields. You can also add your own AS fields to the admin easily.
Thanks
Brian Carpenter
Was just looking for this, thanks.
Notifications
You’re not receiving notifications from this thread.