Active Admin : Can't access show/edit pages

1.1k Views Asked by At

I'm having an issue with Active Admin. Here are the versions :

  • ruby '2.2.1'

  • rails '4.2.0'

  • activeadmin : 1.0.0.pre1

  • arbre : 1.0.3 (mentioning this one because it seems to be linked to my issue somehow)

We upgraded to rails 4.2 and had to upgrade activeadmin as well (from 0.5). After a couple of tweaks (especially the authorization system) everything seems to be fine, except for 1 big issue : I can only access the index pages. When going to a page with an ID (for example : "http://localhost:3000/admin/companies/2968"), I am getting this error :

No route matches {:action=>"edit", :controller=>"admin/companies", :format=>nil, :id=> #{User id: nil, [all user attributes with nil value]}}. Missing required keys: [:id]

Looks like the param[:id] got changed to an empty user somehow, which of course makes it break.

Here's what I know :

  • when putting a binding.pry on top of my ApplicationController and inspecting the params, I get {:action=>"edit", :controller=>"admin/companies", :format=>nil, :id=>2968} (so no problem here)

  • the lines that raise the error are :

active_admin/resource/show.html.arb

-> arbre/element/builder_method.rb#insert_tag

-> arbre/element/builder_method.rb#build_tag

-> actionpack/actiondispatch/journey/formatter#generate (when this method is called, the path_parameters ID value is already corrupted, which raises the error)

Any idea why my ID parameter is not interpreted correctly / where I could look further ?

EDIT >> I have this in my routes.rb

ActiveAdmin.routes(self)
devise_for :admin_users, ActiveAdmin::Devise.config

And the generated routes look fine with rake routes (in this particular example, I have admin/companies#edit admin_company GET /admin/companies/:id(.:format)

EDIT2 >> In case it wasn't clear, this happens for all show pages. If I go to http://localhost:3000/admin/projects/ for example, it works fine, but http://localhost:3000/admin/projects/23815 gives me id = empty user as well

1

There are 1 best solutions below

0
On

I don't recognize this issue, but 0.5 is a very old release. In my experience we had to upgrade in steps, e.g. Rails 3.2/AA 0.6 to narrow down the cause of various issues. Looking back through the old CHANGELOG I did find this fix in 0.6.1 which may be related to your problem.