railsadminteam / rails_admin

RailsAdmin is a Rails engine that provides an easy-to-use interface for managing your data
MIT License
7.89k stars 2.26k forks source link

LocalJumpError in RailsAdmin::Main#show #3320

Closed Shalashtein closed 3 years ago

Shalashtein commented 3 years ago

I have a single model that's creating this issue, the model appears in the index page, however the error is raised when I try to show, edit, or delete it in the Rail Admin Dashboard (it works fine in the app, the error is only raised in the Rails Admin dashboard.

The error I recieve is:

LocalJumpError in RailsAdmin::Main#show
Showing /home/shalashtein/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/bundler/gems/rails_admin-f0c46f1e128b/app/views/rails_admin/main/show.html.haml where line #3 raised:

no block given

Extracted source (around line #101):
# Reader for the association's value unformatted
        def value
          bindings[:object].send(association.name)
        end

Model:

class Product < ApplicationRecord
  belongs_to :catch
  has_many :items, dependent: :destroy
end

Controller:

class ProductsController < ApplicationController
  before_action :set_product, only: [:show, :edit, :update, :destroy]

  # GET /products
  # GET /products.json
  def index
    @products = Product.all
  end

  # GET /products/1
  # GET /products/1.json
  def show
    authorize @product, policy_class: ProductPolicy
  end

  # GET /products/new
  def new
    @product = Product.new
    authorize @product, policy_class: ProductPolicy
  end

  # GET /products/1/edit
  def edit
    authorize @product, policy_class: ProductPolicy
  end

  # POST /products
  # POST /products.json
  def create
    @product = Product.new(product_params)
    authorize @product, policy_class: ProductPolicy
    respond_to do |format|
      if @product.save
        format.html { redirect_to @product, notice: 'Product was successfully created.' }
        format.json { render :show, status: :created, location: @product }
      else
        format.html { render :new }
        format.json { render json: @product.errors, status: :unprocessable_entity }
      end
    end
  end

  # PATCH/PUT /products/1
  # PATCH/PUT /products/1.json
  def update
    authorize @product, policy_class: ProductPolicy
    respond_to do |format|
      if @product.update(product_params)
        format.html { redirect_to @product, notice: 'Product was successfully updated.' }
        format.json { render :show, status: :ok, location: @product }
      else
        format.html { render :edit }
        format.json { render json: @product.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /products/1
  # DELETE /products/1.json
  def destroy
    authorize @product, policy_class: ProductPolicy
    @product.destroy
    respond_to do |format|
      format.html { redirect_to products_url, notice: 'Product was successfully destroyed.' }
      format.json { head :no_content }
    end
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_product
      @product = Product.find(params[:id])
    end

    # Only allow a list of trusted parameters through.
    def product_params
      params.require(:product).permit(:catch_id, :price)
    end
end

log

rails_admin (f0c46f1e128b) lib/rails_admin/config/fields/association.rb:101:in `catch'
rails_admin (f0c46f1e128b) lib/rails_admin/config/fields/association.rb:101:in `value'
rails_admin (f0c46f1e128b) lib/rails_admin/config/fields/types/belongs_to_association.rb:11:in `block in <class:BelongsToAssociation>'
rails_admin (f0c46f1e128b) lib/rails_admin/config/configurable.rb:75:in `instance_eval'
rails_admin (f0c46f1e128b) lib/rails_admin/config/configurable.rb:75:in `block in register_instance_option'
rails_admin (f0c46f1e128b) lib/rails_admin/config/proxyable/proxy.rb:25:in `method_missing'
rails_admin (f0c46f1e128b) app/views/rails_admin/main/show.html.haml:3
rails_admin (f0c46f1e128b) app/views/rails_admin/main/show.html.haml:3:in `reject'
rails_admin (f0c46f1e128b) app/views/rails_admin/main/show.html.haml:3
rails_admin (f0c46f1e128b) app/views/rails_admin/main/show.html.haml:1:in `each'
rails_admin (f0c46f1e128b) app/views/rails_admin/main/show.html.haml:1
actionview (6.0.3.4) lib/action_view/base.rb:274:in `_run'
actionview (6.0.3.4) lib/action_view/template.rb:185:in `block in render'
activesupport (6.0.3.4) lib/active_support/notifications.rb:182:in `instrument'
actionview (6.0.3.4) lib/action_view/template.rb:385:in `instrument_render_template'
actionview (6.0.3.4) lib/action_view/template.rb:183:in `render'
actionview (6.0.3.4) lib/action_view/renderer/template_renderer.rb:58:in `block (2 levels) in render_template'
actionview (6.0.3.4) lib/action_view/renderer/abstract_renderer.rb:88:in `block in instrument'
activesupport (6.0.3.4) lib/active_support/notifications.rb:180:in `block in instrument'
activesupport (6.0.3.4) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (6.0.3.4) lib/active_support/notifications.rb:180:in `instrument'
actionview (6.0.3.4) lib/action_view/renderer/abstract_renderer.rb:87:in `instrument'
actionview (6.0.3.4) lib/action_view/renderer/template_renderer.rb:57:in `block in render_template'
actionview (6.0.3.4) lib/action_view/renderer/template_renderer.rb:65:in `render_with_layout'
actionview (6.0.3.4) lib/action_view/renderer/template_renderer.rb:56:in `render_template'
actionview (6.0.3.4) lib/action_view/renderer/template_renderer.rb:13:in `render'
actionview (6.0.3.4) lib/action_view/renderer/renderer.rb:61:in `render_template_to_object'
actionview (6.0.3.4) lib/action_view/renderer/renderer.rb:29:in `render_to_object'
actionview (6.0.3.4) lib/action_view/rendering.rb:117:in `block in _render_template'
actionview (6.0.3.4) lib/action_view/base.rb:304:in `in_rendering_context'
actionview (6.0.3.4) lib/action_view/rendering.rb:116:in `_render_template'
actionpack (6.0.3.4) lib/action_controller/metal/streaming.rb:218:in `_render_template'
actionview (6.0.3.4) lib/action_view/rendering.rb:103:in `render_to_body'
actionpack (6.0.3.4) lib/action_controller/metal/rendering.rb:52:in `render_to_body'
actionpack (6.0.3.4) lib/action_controller/metal/renderers.rb:142:in `render_to_body'
actionpack (6.0.3.4) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (6.0.3.4) lib/action_controller/metal/rendering.rb:36:in `render'
actionpack (6.0.3.4) lib/action_controller/metal/instrumentation.rb:44:in `block (2 levels) in render'
activesupport (6.0.3.4) lib/active_support/core_ext/benchmark.rb:14:in `block in ms'
/home/shalashtein/.rbenv/versions/2.6.6/lib/ruby/2.6.0/benchmark.rb:308:in `realtime'
activesupport (6.0.3.4) lib/active_support/core_ext/benchmark.rb:14:in `ms'
actionpack (6.0.3.4) lib/action_controller/metal/instrumentation.rb:44:in `block in render'
actionpack (6.0.3.4) lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'
activerecord (6.0.3.4) lib/active_record/railties/controller_runtime.rb:34:in `cleanup_view_runtime'
actionpack (6.0.3.4) lib/action_controller/metal/instrumentation.rb:43:in `render'
remotipart (1.4.4) lib/remotipart/render_overrides.rb:23:in `render'
rails_admin (f0c46f1e128b) lib/rails_admin/config/actions/show.rb:23:in `block (4 levels) in <class:Show>'
actionpack (6.0.3.4) lib/action_controller/metal/mime_responds.rb:214:in `respond_to'
rails_admin (f0c46f1e128b) lib/rails_admin/config/actions/show.rb:21:in `block (2 levels) in <class:Show>'
rails_admin (f0c46f1e128b) app/controllers/rails_admin/main_controller.rb:22:in `instance_eval'
rails_admin (f0c46f1e128b) app/controllers/rails_admin/main_controller.rb:22:in `show'
actionpack (6.0.3.4) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (6.0.3.4) lib/abstract_controller/base.rb:195:in `process_action'
actionpack (6.0.3.4) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (6.0.3.4) lib/abstract_controller/callbacks.rb:42:in `block in process_action'
activesupport (6.0.3.4) lib/active_support/callbacks.rb:135:in `run_callbacks'
actionpack (6.0.3.4) lib/abstract_controller/callbacks.rb:41:in `process_action'
actionpack (6.0.3.4) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (6.0.3.4) lib/action_controller/metal/instrumentation.rb:33:in `block in process_action'
activesupport (6.0.3.4) lib/active_support/notifications.rb:180:in `block in instrument'
activesupport (6.0.3.4) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (6.0.3.4) lib/active_support/notifications.rb:180:in `instrument'
actionpack (6.0.3.4) lib/action_controller/metal/instrumentation.rb:32:in `process_action'
actionpack (6.0.3.4) lib/action_controller/metal/params_wrapper.rb:245:in `process_action'
activerecord (6.0.3.4) lib/active_record/railties/controller_runtime.rb:27:in `process_action'
actionpack (6.0.3.4) lib/abstract_controller/base.rb:136:in `process'
actionview (6.0.3.4) lib/action_view/rendering.rb:39:in `process'
actionpack (6.0.3.4) lib/action_controller/metal.rb:190:in `dispatch'
actionpack (6.0.3.4) lib/action_controller/metal.rb:254:in `dispatch'
actionpack (6.0.3.4) lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
actionpack (6.0.3.4) lib/action_dispatch/routing/route_set.rb:33:in `serve'
actionpack (6.0.3.4) lib/action_dispatch/journey/router.rb:49:in `block in serve'
actionpack (6.0.3.4) lib/action_dispatch/journey/router.rb:32:in `each'
actionpack (6.0.3.4) lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack (6.0.3.4) lib/action_dispatch/routing/route_set.rb:834:in `call'
railties (6.0.3.4) lib/rails/engine.rb:527:in `call'
railties (6.0.3.4) lib/rails/railtie.rb:190:in `public_send'
railties (6.0.3.4) lib/rails/railtie.rb:190:in `method_missing'
actionpack (6.0.3.4) lib/action_dispatch/routing/mapper.rb:19:in `block in <class:Constraints>'
actionpack (6.0.3.4) lib/action_dispatch/routing/mapper.rb:48:in `serve'
actionpack (6.0.3.4) lib/action_dispatch/journey/router.rb:49:in `block in serve'
actionpack (6.0.3.4) lib/action_dispatch/journey/router.rb:32:in `each'
actionpack (6.0.3.4) lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack (6.0.3.4) lib/action_dispatch/routing/route_set.rb:834:in `call'
rack-pjax (1.1.0) lib/rack/pjax.rb:12:in `call'
remotipart (1.4.4) lib/remotipart/middleware.rb:32:in `call'
warden (1.2.9) lib/warden/manager.rb:36:in `block in call'
warden (1.2.9) lib/warden/manager.rb:34:in `catch'
warden (1.2.9) lib/warden/manager.rb:34:in `call'
rack (2.2.3) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.2.3) lib/rack/etag.rb:27:in `call'
rack (2.2.3) lib/rack/conditional_get.rb:27:in `call'
rack (2.2.3) lib/rack/head.rb:12:in `call'
actionpack (6.0.3.4) lib/action_dispatch/http/content_security_policy.rb:18:in `call'
rack (2.2.3) lib/rack/session/abstract/id.rb:266:in `context'
rack (2.2.3) lib/rack/session/abstract/id.rb:260:in `call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/cookies.rb:648:in `call'
activerecord (6.0.3.4) lib/active_record/migration.rb:567:in `call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
activesupport (6.0.3.4) lib/active_support/callbacks.rb:101:in `run_callbacks'
actionpack (6.0.3.4) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/debug_exceptions.rb:32:in `call'
web-console (4.1.0) lib/web_console/middleware.rb:132:in `call_app'
web-console (4.1.0) lib/web_console/middleware.rb:28:in `block in call'
web-console (4.1.0) lib/web_console/middleware.rb:17:in `catch'
web-console (4.1.0) lib/web_console/middleware.rb:17:in `call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (6.0.3.4) lib/rails/rack/logger.rb:37:in `call_app'
railties (6.0.3.4) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (6.0.3.4) lib/active_support/tagged_logging.rb:80:in `block in tagged'
activesupport (6.0.3.4) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (6.0.3.4) lib/active_support/tagged_logging.rb:80:in `tagged'
railties (6.0.3.4) lib/rails/rack/logger.rb:26:in `call'
sprockets-rails (3.2.2) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
request_store (1.5.0) lib/request_store/middleware.rb:19:in `call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/request_id.rb:27:in `call'
rack (2.2.3) lib/rack/method_override.rb:24:in `call'
rack (2.2.3) lib/rack/runtime.rb:22:in `call'
activesupport (6.0.3.4) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/static.rb:126:in `call'
rack (2.2.3) lib/rack/sendfile.rb:110:in `call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/host_authorization.rb:82:in `call'
webpacker (4.3.0) lib/webpacker/dev_server_proxy.rb:23:in `perform_request'
rack-proxy (0.6.5) lib/rack/proxy.rb:57:in `call'
railties (6.0.3.4) lib/rails/engine.rb:527:in `call'
puma (4.3.6) lib/puma/configuration.rb:228:in `call'
puma (4.3.6) lib/puma/server.rb:713:in `handle_request'
puma (4.3.6) lib/puma/server.rb:472:in `process_client'
puma (4.3.6) lib/puma/server.rb:328:in `block in run'
puma (4.3.6) lib/puma/thread_pool.rb:134:in `block in spawn_thread'

Ruby version: 2.6.6 Rails 6

mshibuya commented 3 years ago

Dup of #3253.