We've moved discussions to Discord

Dashboards : AccountUsers : Administrate : options_for_select ? (Beginner to Intermediate)...

Donal O Duibhir
I've gone through the Administrate doco and figured out how to customize views to show resource names + ids as opposed to just resource.class + id...

accountusers_more_info.png 47.4 KB


but am stuck on how to customize the displayed text for options_for_select

accountusers.png 55.1 KB


in their (Administrate's) `belongs_to` associations field for the dropdown `AccountUsers` in the Jumpstart dashboard? This may be a pure Administrate question but wondering how best to overload -> app/views/admin/account_users/_form.html.erb snippet for dropdown options?

  <% page.attributes.each do |attribute| -%>
    <div class="field-unit field-unit--<%= attribute.html_class %> field-unit--<%= requireness(attribute) %>">
      <%= render_field attribute, f: f %>
    </div>
  <% end -%>

Perhaps via their ..../lib/administrate/field/belongs_to.rb which am guessing I could also do something with their /app/views/fields/belongs_to/_form.html.rb i.e. move in to the Jumpstart project folder to overload?

their belongs_to.rb has:
      def associated_resource_options
        candidate_resources.map do |resource|
          [display_candidate_resource(resource), resource.send(primary_key)]
        end
      end
and
      def display_candidate_resource(resource)
        associated_dashboard.display_resource(resource)
      end
but I'm getting in to deeper territory where I think I would break multiple things by touching the gem's internals?

Is there any quick way to have a better text option than the below (i.e. account.name + account.id) without going nuts?

accountusers.png 55.1 KB


Notifications
You’re not receiving notifications from this thread.