-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Warning: method status
already defined
#5316
Comments
Can you provide a stacktrace? |
I am seeing the same warning, but for a different method. This also happened when I upgraded to v1.2.1. It looks like this commit was added to warn about redefining a controller method. In my instance, we added the method to override the default controller's method. Maybe we could add a way to silence the message? |
Sorry for the delay; I was pulled to other projects. Back to this now. There are no stack traces to show as it doesn't generate an exception. Simply a warning in the logs. Since version 1.3.0, when this shows up, the performance of the site is so slow such that it is unusable. Any suggestions would be great. An example from the dev logs; note the long delay in response and the warning interspersed in the logs. This type of request should be a few seconds. I killed the server after 30 or so. Side note; the config as asset logs OFF, yet they show up anyway. I've raised a separate bug for this
|
Another note; this message shows up when I start a console and initially start up the server. It almost seems like the server is being restarted over and over again when the performance goes bad. |
I've noticed the warning My
However, I also see two "Restore Account" buttons in on my show page. I'll try to setup an environment recreating this issue to help debug :) Edit: I was able to remove this warning & fix my duplicate button problem by changing my production configuration to be :
|
A useful tool for finding prior method definitions is
Overriding If you are deliberately and knowingly overriding an existing method you can use |
Here is what I get when I launch a console in my project:
Similar results if I break in a controller and try to find the definition. |
TL;DR rename your member_action away from |
I managed to recreated the same error in a blank rails project ( https://github.com/MikeRogers0/ActiveAdminDefinedMethodDemo ) - @louffoster Would I be right to say you're using multiple engines in your app? |
Sorry, no. It is a very old project, and I think it had some before I inherited it a few years ago, but not now. It is in a public repo here: https://github.com/uvalib/tracksys |
I am getting a lot of these as well, when starting the server and loading the console. For example this resource
triggers
Using latest rails version, bootsnap, etc. |
I'm also getting this for several "login" actions. Changing to "log_in" gets rid of them when running the rails server, but when running my specs, I still get one instance of "method 'log_in' already defined". Also, I get the same message for three other member_actions, and they are definitely not colliding with anything defined somewhere else - the names are unique to the app and to one admin resource. Latest rails (5.2.1) and bootsnap. |
Just something I noticed while trying to find a fix in https://github.com/MikeRogers0/ActiveAdminDefinedMethodDemo If I add
I think perhaps |
Good news, I found a way to fix this I think 😊 Move your folder # == Load Paths
#
# If you're noticing a warning in your logs/console like:
# "Warning: method `restore_resource` already defined"
# Move your `app/admin` folder into `lib/admin`
# Then manually add the load path like:
config.load_paths += Dir[Rails.root.join('lib', 'admin')] |
MikeRogers0, I get initialization errors during load if I do this. I am on rails 5.1.6. |
@bdezonia What initialization errors are you seeing? |
Here is the beginning of a stack trace: DOM10300:reggie_rails bdezonia$ rails s lib/admin/contact.rb exists and is organized like such: ActiveAdmin.register Contact do much much stuffend Let me know if you need more info. Thanks. |
@bdezonia What is defined in |
Filters, batch actions, collection_actions, controller methods, and a form. Over 350 lines; I don't really want to post it. |
@bdezonia Is the register something like: ActiveAdmin.register Admin::Contact do or ActiveAdmin.register Contact do ? Reason I ask is because the error message reads: Also if you'd prefer to share privately, I'm super eager to help debug to confirm what's up with my fix :) |
It's like this:
I have shared the code with you privately. |
Thanks so much @MikeRogers0 for helping out here! It'd be great if we could somehow get a platform independent reproduction via |
@deivid-rodriguez Did you checkout from MikeRogers0-YouTube/ActiveAdminDefinedMethodDemo@77cace4 - this commit? |
Not really 🤣, that explains everything. I'll have a look again! |
Hi! Any update on this issue? I am also seeing this error whenever using Edit: I solved this by replacing any
with
|
I can confirm that this causes a warning: member_action :reset_user_password do
user = User.find(params[:id])
user.send_reset_password_instructions
redirect_to(admin_user_path(user),
notice: "Password reset email sent to #{user.email}")
end While this does not: controller do
def reset_user_password
user = User.find(params[:id])
user.send_reset_password_instructions
redirect_to(admin_user_path(user),
notice: "Password reset email sent to #{user.email}")
end
end |
Just upgraded to version 1.2.1 and now constantly get this warning message:
Warning: method
statusalready defined
No idea what is causing it.
Running rails 5.1.4, Ruby 2.4.1
The text was updated successfully, but these errors were encountered: