macfanatic / active_admin-state_machine

Provides easy integration between ActiveAdmin and your state machine on resources
MIT License
31 stars 20 forks source link

warning: method already defined in rails 6.1.4 #12

Open dannyy83 opened 3 years ago

dannyy83 commented 3 years ago

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>

macfanatic commented 3 years ago

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

Thanks!

dannyy83 commented 3 years ago

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

dannyy83 commented 3 years ago

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 commented 3 years ago

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
macfanatic commented 3 years ago

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).

dannyy83 commented 3 years ago

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.

macfanatic commented 3 years ago

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.