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

Coded human_name is being overwritten #37

Open
vanboom opened this issue Jul 31, 2024 · 1 comment
Open

Coded human_name is being overwritten #37

vanboom opened this issue Jul 31, 2024 · 1 comment

Comments

@vanboom
Copy link

vanboom commented Jul 31, 2024

new_state.human_name = ->(state, klass) { translate(klass, :state, state.name) }

This code forces the human_name via translation even when the human name is hard coded in the state definition.
state-machines/state_machines#76 (comment)

For example, setting the human_name should be supported like this...

class MyClass
  state_machine :state, initial: :pending do
    state :pending, human_name: "To Do"
    state :in_progress, human_name: "In Progress"
  end
end
irb(main):154:0> MyClass.human_state_name :pending
=> "To Do"

Recommend changing line #507 to

          new_state.human_name ||= ->(state, klass) { translate(klass, :state, state.name) }

and only using the translation for the human state name if it is not coded in the state definition.

Thanks for your consideration!

@vanboom
Copy link
Author

vanboom commented Jul 31, 2024

Please consider our PR to resolve this issue.

#38 (comment)

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant