Administrate: I have a model called `Action`. How do I avoid the conflict with the `action` parameter?

Created on 11 Apr 2019  路  2Comments  路  Source: thoughtbot/administrate

My model called Action has a dashboard, but this error happens preventing it from loading:

undefined method `fetch' for "index":String

Which comes from this part of administrate/application_controller.rb around line 103:

    def order
      @order ||= Administrate::Order.new(
        params.fetch(resource_name, {}).fetch(:order, nil), # <-- error here
        params.fetch(resource_name, {}).fetch(:direction, nil),
      )
    end

The problem is that resource_name is action, which conflicts with the normal param called action which tells us that in this case, we want the index. We therefore get 'index' from the params, not nil which would give us the default empty object, which fetch would work on.

Is there a way around this?

bug models

Most helpful comment

I also have a model called Action, and I'm running across this issue. +1

All 2 comments

I also have a model called Action, and I'm running across this issue. +1

I can confirm that this is an issue at the moment. Currently, we get an error when link_to() receives a value of action that is not a route action. Unfortunately our sorting parameters create this situation if a model is called "Action" (and I guess also if called "Controller"), so this breaks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rmarronnier picture rmarronnier  路  4Comments

dbryand picture dbryand  路  3Comments

amyin picture amyin  路  4Comments

trandoanhung1991 picture trandoanhung1991  路  3Comments

MatthiasRMS picture MatthiasRMS  路  3Comments