Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
stanmx opened this issue Nov 7, 2011 · 16 comments
Closed

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

stanmx opened this issue Nov 7, 2011 · 16 comments
Labels
Milestone

Comments

@stanmx
Copy link

stanmx commented Nov 7, 2011

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
Copy link

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
Copy link

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

@Finnerty
Copy link

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
Copy link

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
Copy link
Contributor

ramigg commented Dec 3, 2011

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

10x!

@simontol
Copy link

simontol commented Dec 5, 2011

Same here. Any news? Rails 3.1.3 ActiveAdmin 0.3.4

@eliang
Copy link

eliang commented Dec 6, 2011

+1 for a fix

@chexton
Copy link

chexton commented Dec 12, 2011

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

@hoangnghiem
Copy link

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
Copy link

fro commented Dec 19, 2011

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

@hoangnghiem
Copy link

Yes, I did. Not sure why it does not show in the form for you. It just a field like other fields and nothing more.

On Dec 19, 2011, at 5:36 PM, Pourrier François wrote:

@hoangnghiem Did you try your solution? The password field doesn't show in the form.


Reply to this email directly or view it on GitHub:
#733 (comment)

@fro
Copy link

fro commented Dec 19, 2011

The important thing is: It is working.

@hron84
Copy link
Contributor

hron84 commented Jan 17, 2012

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

@nacengineer
Copy link

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
Copy link
Contributor

gregbell commented Feb 3, 2012

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 as completed Feb 3, 2012
@hron84
Copy link
Contributor

hron84 commented Feb 4, 2012

@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
Labels
Projects
None yet
Development

No branches or pull requests