Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Could not find a valid mapping for #<AdminUser ... #733

Closed
stanmx opened this Issue · 16 comments
@stanmx

Hi,

I follow the steps of https://github.com/gregbell/active_admin/wiki/Your-First-Admin-Resource%3A-AdminUser to create new users, but when i try to access other sections of active_admin i received the next message:

RuntimeError in Admin::AdminUsersController#create

Could not find a valid mapping for #<AdminUser id: 2 ....

I check the steps and my code is like the tutorial. Do you have any suggestions? thanks!

@techpoint

I started getting the same issue when I first had a Device instance set-up for a User model, then tried to add active_admin per the above referenced method. I too am stumped.

@jasonmcbride

I am having the same issue is there no solution for this yet?

@Finnerty

I have found the problem to be in the following line in admin_user.rb

after_create { |admin| admin.send_reset_password_instructions }

If you comment it out, it works.

Will try to further understand why, but in the meantime if you don't absolutely need this feature. It might help

@Finnerty

I found the problem. It is in the following function inside the devise:

def self.find_scope!(duck)
    case duck
    when String, Symbol
        return duck
    when Class
        Devise.mappings.each_value { |m| return m.name if duck <= m.to }
    else
        Devise.mappings.each_value { |m| return m.name if duck.is_a?(m.to) }
    end

    raise "Could not find a valid mapping for #{duck.inspect}"
end

The problem (as discussed here: http://www.ruby-forum.com/topic/1032905) is that the provided instance of AdminUser does not respond to is_a?(AdminUser) as the two are not the same due a code reloading quirks in Rails. As it keeps happening to me in 3.1.0 it seems that it has not been resolved yet.

To avoid the problem enable the class caching in development.rb

config.cache_classes = true

Please post better solution when available

@ramigg

Is there any solution for the problem except cache clases in development?

10x!

@simontol

Same here. Any news? Rails 3.1.3 ActiveAdmin 0.3.4

@eliang

+1 for a fix

@chexton

Confirming that I also have the same issue here. Have not yet found a suitable solution other than as mentioned above.

@hoangnghiem

just add a password field to form like below:

form do |f|
f.inputs "Admin Details" do
f.input :email
f.input :password
end
f.buttons
end

In the create new user page, enter a password beside the email. Also remove after_create callback in model.

@fro

And don't forget to restart the server if you change the development.rb file with: config.cache_classes = true

@hoangnghiem
@fro

The important thing is: It is working.

@hron84

I'd like see an another solution too... even if there is a workaround (and not a solution!) to it.

@nacengineer

Out of curiosity do you have a "is_a?" method defined in your Admin Controller? You may be monkey patching the is_a? method on the Object class. http://ruby-doc.org/core-1.9.3/Object.html#method-i-is_a-3F

If this is the case just change your is_a? method in your Admin class to is_an? or some other method and it should work.

@gregbell
Owner

The class reloading issues that caused this have been fixed in 0.4.0. Please re-open this ticket if it continues to be an issue.

@gregbell gregbell closed this
@hron84

@gregbell and what about locale reloading issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.