Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesnt work with Rails_admin gem #89

Open
bhushangahire opened this issue Aug 2, 2018 · 6 comments
Open

Doesnt work with Rails_admin gem #89

bhushangahire opened this issue Aug 2, 2018 · 6 comments

Comments

@bhushangahire
Copy link

Any workaround to get delete working with rails admin gem.
Its trying to find relation but breaks

undefined method constantize' for nil:NilClass`

@olliebennett
Copy link

Please could you share a little more context / code?

What are you trying to delete, and how? Via the rails_admin UI?

@asnad
Copy link

asnad commented Nov 20, 2019

Getting same error in rails 4.2 and rails_admin 1.3.0
Screenshot from 2019-11-20 21-01-06

@asnad
Copy link

asnad commented Dec 4, 2019

Please could you share a little more context / code?

What are you trying to delete, and how? Via the rails_admin UI?

Please check the screenshot

@asnad
Copy link

asnad commented Dec 4, 2019

@bhushangahire did you find the fix??

@asnad
Copy link

asnad commented Dec 5, 2019

I fixed it by overriding app/views/rails_admin/main/_delete_notice.html.erb by putting following contents

<% object = delete_notice %>
<li style="display:block; margin-top:10px">
  <span class="label label-default">
    <%= @abstract_model.pretty_name %>
  </span>
  <% wording = object.send(@model_config.object_label_method) %>
  <% if show_action = action(:show, @abstract_model, object) %>
    <%= link_to(wording, url_for(action: show_action.action_name, model_name: @abstract_model.to_param, id: object.id), class: 'pjax') %>
  <% else %>
    <%= wording %>
  <% end %>
  <ul>
    <% @abstract_model.each_associated_children(object) do |association, children| %>
      <% humanized_association = @abstract_model.model.human_attribute_name association.name %>
      <% limit = children.count > 12 ? 10 : children.count %>
      <% children.first(limit).each do |child| %>
        <%= content_tag :li, class: dom_class(child) do %>
          <% if child.class.name != "RailsSettings::SettingObject" %> #condition added
            <% child_config = RailsAdmin.config(child) %>
            <%= humanized_association.singularize %>
            <% wording = child.send(child_config.object_label_method) %>
            <% if child.id && (show_action = action(:show, child_config.abstract_model, child)) %>
              <%= link_to(wording, url_for(action: show_action.action_name, model_name: child_config.abstract_model.to_param, id: child.id), class: 'pjax') %>
            <% else %>
              <%= wording %>
            <% end %>
          <% end %>
        <% end %>
      <% end %>
      <% if children.count > limit %>
        <li>
          <%= t('admin.misc.more', count: children.count - limit, models_name: humanized_association) %>
        </li>
      <% end %>
    <% end %>
  </ul>
</li>

@favour121
Copy link

Version 2.5.0 doesn't work with RailsAdmin. It fails as soon as you try viewing any model that uses has_settings.

Returned error and stacktrace:

Error: undefined method `constantize' for nil:NilClass

Stacktrace:

ledermann-rails-settings (2.5.0) lib/rails-settings/setting_object.rb:78:in _target_class' ledermann-rails-settings (2.5.0) lib/rails-settings/setting_object.rb:82:in _setting?'
ledermann-rails-settings (2.5.0) lib/rails-settings/setting_object.rb:28:in respond_to?' rails_admin (3.1.2) lib/rails_admin/config/model.rb:66:in block (2 levels) in class:Model'
rails_admin (3.1.2) lib/rails_admin/config/model.rb:66:in each' rails_admin (3.1.2) lib/rails_admin/config/model.rb:66:in detect'
rails_admin (3.1.2) lib/rails_admin/config/model.rb:66:in block in <class:Model>' rails_admin (3.1.2) lib/rails_admin/config/configurable.rb:77:in instance_eval'
rails_admin (3.1.2) lib/rails_admin/config/configurable.rb:77:in block in register_instance_option' rails_admin (3.1.2) lib/rails_admin/config/lazy_model.rb:66:in method_missing'
rails_admin (3.1.2) app/helpers/rails_admin/application_helper.rb:74:in wording_for' rails_admin (3.1.2) app/controllers/rails_admin/main_controller.rb:36:in action_missing'
actionpack (7.0.6) lib/abstract_controller/base.rb:229:in _handle_action_missing' actionpack (7.0.6) lib/action_controller/metal/basic_implicit_render.rb:6:in send_action'
actionpack (7.0.6) lib/abstract_controller/base.rb:215:in process_action' actionpack (7.0.6) lib/action_controller/metal/rendering.rb:165:in process_action'
actionpack (7.0.6) lib/abstract_controller/callbacks.rb:234:in block in process_action' activesupport (7.0.6) lib/active_support/callbacks.rb:118:in block in run_callbacks'
actiontext (7.0.6) lib/action_text/rendering.rb:20:in with_renderer' actiontext (7.0.6) lib/action_text/engine.rb:69:in block (4 levels) in class:Engine'
activesupport (7.0.6) lib/active_support/callbacks.rb:127:in instance_exec' activesupport (7.0.6) lib/active_support/callbacks.rb:127:in block in run_callbacks'
activesupport (7.0.6) lib/active_support/callbacks.rb:138:in run_callbacks' actionpack (7.0.6) lib/abstract_controller/callbacks.rb:233:in process_action'
actionpack (7.0.6) lib/action_controller/metal/rescue.rb:23:in process_action' actionpack (7.0.6) lib/action_controller/metal/instrumentation.rb:67:in block in process_action'
activesupport (7.0.6) lib/active_support/notifications.rb:206:in block in instrument' activesupport (7.0.6) lib/active_support/notifications/instrumenter.rb:24:in instrument'
activesupport (7.0.6) lib/active_support/notifications.rb:206:in instrument' actionpack (7.0.6) lib/action_controller/metal/instrumentation.rb:66:in process_action'
actionpack (7.0.6) lib/action_controller/metal/params_wrapper.rb:259:in process_action' searchkick (5.2.4) lib/searchkick/controller_runtime.rb:15:in process_action'
activerecord (7.0.6) lib/active_record/railties/controller_runtime.rb:27:in process_action' actionpack (7.0.6) lib/abstract_controller/base.rb:151:in process'
actionview (7.0.6) lib/action_view/rendering.rb:39:in process' actionpack (7.0.6) lib/action_controller/metal.rb:188:in dispatch'
actionpack (7.0.6) lib/action_controller/metal.rb:251:in dispatch' actionpack (7.0.6) lib/action_dispatch/routing/route_set.rb:49:in dispatch'
actionpack (7.0.6) lib/action_dispatch/routing/route_set.rb:32:in serve' actionpack (7.0.6) lib/action_dispatch/journey/router.rb:50:in block in serve'
actionpack (7.0.6) lib/action_dispatch/journey/router.rb:32:in each' actionpack (7.0.6) lib/action_dispatch/journey/router.rb:32:in serve'
actionpack (7.0.6) lib/action_dispatch/routing/route_set.rb:852:in call' railties (7.0.6) lib/rails/engine.rb:530:in call'
railties (7.0.6) lib/rails/railtie.rb:226:in public_send' railties (7.0.6) lib/rails/railtie.rb:226:in method_missing'
actionpack (7.0.6) lib/action_dispatch/routing/mapper.rb:19:in block in <class:Constraints>' actionpack (7.0.6) lib/action_dispatch/routing/mapper.rb:48:in serve'
actionpack (7.0.6) lib/action_dispatch/journey/router.rb:50:in block in serve' actionpack (7.0.6) lib/action_dispatch/journey/router.rb:32:in each'
actionpack (7.0.6) lib/action_dispatch/journey/router.rb:32:in serve' actionpack (7.0.6) lib/action_dispatch/routing/route_set.rb:852:in call'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants