Stephen Corwin
Stephen Corwin

Reputation: 1007

ActiveAdmin pulling up wrong record by id

Here's one I just can't get to the bottom of:

I'm using ActiveAdmin and I've got a tab for users (powered by Devise). For the longest time everything worked perfectly. Then today I went to view one of the users and noticed that for some reason, it pulled up MY user account instead of the user's that I had clicked on. I tried the show page as well with the same result. It does this for all users. I have no idea when this started... prior to today I hadn't clicked on either of these actions in quite some time... at least several weeks. But the point is I must have done something, and now I can't see any users besides myself.

I checked the logs after visiting /admin/users/153 and saw:

Parameters: {"id"=>"153"}
  User Load (0.6ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 2 LIMIT 1
  AdminUser Load (0.5ms)  SELECT "admin_users".* FROM "admin_users" WHERE "admin_users"."id" = 3 LIMIT 1

It's selecting my user id (2) instead of the one in the params hash (153). I haven't modified anything in ActiveAdmin, and to the best of my knowledge, I'm not using anything that would interfere with it... so I'm stumped.

Any thoughts?

Upvotes: 0

Views: 156

Answers (1)

Codelism
Codelism

Reputation: 184

Not sure my answer will help you but I faced a similar issue. In my case, I set @challenge in application_controller where I can use from anywhere in any controller. The problem arose when I edited a Challenge record by Active admin, it updated the @challenge I set earlier. It took me couple hours to figure this out and it turned out to be just because sharing class variable.

Upvotes: 1

Related Questions