7

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

BPruvost
  • 503
  • 2
  • 5
  • 16
  • Please add the `app/admin/company.rb` file to your question. – scarver2 Aug 31 '15 at 17:47
  • Also, rename your `config/initializers/active_admin.rb` to `config/initializers/active_admin.rb.off` and re-run ActiveAdmin's installer `bundle exec rails g active_admin:install` to see if that remedies the issue. Make sure the `ActiveAdmin.routes(self)` is in your `routes.rb` file. Also, from the Rails console, make sure the Company<->User association is working as hinted at by the error message. – scarver2 Aug 31 '15 at 18:37
  • Thx for the reply. Re-running AA's installer didn't solve it. I added the details for the routes in the post. The company / user association works fine, and the admin/company.rb was working before the update, this particular issue actually happens before even going to this file, and for all models ! Every admin/model/id route is broken – BPruvost Sep 01 '15 at 09:06
  • Swap the order of the two routes. If that doesn't work, would you be willing to add me to your repo so that I can investigate further? – scarver2 Sep 02 '15 at 04:06
  • It's really hard to say without the actual code. Do you have any monkey-patches for AA? It breaks when building the link to edit page. Are you building it yourself? – faron Feb 16 '16 at 07:58

1 Answers1

0

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.

Piers C
  • 2,880
  • 1
  • 23
  • 29