active_admin-state_machine icon indicating copy to clipboard operation
active_admin-state_machine copied to clipboard

warning: method already defined in rails 6.1.4

Open dannyy83 opened this issue 4 years ago • 7 comments

Hi there,

I'm using active_admin-state_machine with rails v6.1.4 and ActiveAdmin v2.9.0

When rails is launched, I get warnings for each state_action block defined in my active admin classes: Warning: method <state action> already defined in <ActiveAdmin Controller>

dannyy83 avatar Jul 29 '21 11:07 dannyy83

Could you by chance provide a stack trace so I can more easily determine what method it's conflicting with?

Thanks!

macfanatic avatar Jul 29 '21 12:07 macfanatic

Unfortunately there is no stack trace, just those warnings to stdout.

dannyy83 avatar Jul 29 '21 12:07 dannyy83

To give you a more concrete example:

ActiveAdmin.register Book do
  state_action :review do
  end
end
Warning: method `review` already defined in Admin::BooksController

dannyy83 avatar Jul 29 '21 13:07 dannyy83

This post explains the issue: https://github.com/activeadmin/activeadmin/issues/5316

However, the suggested solution does not work for me since some of my state_actions use :confirm e.g.

ActiveAdmin.register Book do
  state_action :review, confirm: -> { 'Are you sure?' } do
  end
end

dannyy83 avatar Jul 29 '21 14:07 dannyy83

Thanks for providing more input on the issue, just checking in to see if you've found a work-around since we last spoke?

Otherwise I'll see what I can dig up from the linked issue and rails 6.1 (that we now support, yay with #13).

macfanatic avatar Aug 31 '21 19:08 macfanatic

Hi @macfanatic,

I haven't found a work-around. These are just warnings printed to stderr and everything still works as intended so we are ignoring them for now... However I am afraid that future versions of rails may break.

dannyy83 avatar Sep 01 '21 01:09 dannyy83

Could you clone the repo and see if starting the rails app produces those warnings in the dummy app for you?

I do not see those logged when starting a console nor when running the server. I'm also curious if they are still present on the most recent pre-release of the library.

macfanatic avatar Sep 01 '21 15:09 macfanatic