Open iabdulin opened 11 years ago
Hey @iabdulin -
Any chance the code that's referencing the state name is modifying the string in-place? I can't reproduce in a simple example using state_machine 1.2.0:
require 'state_machine'
class Ticket
state_machine do
event :next_step do
transition :new => :issue_details_collected
transition :issue_details_collected => :carrier_details_collected
transition :carrier_details_collected => :closed
end
state :new, :human_name => 'Issue Details'
state :issue_details_collected, :human_name => 'Carrier Details' do
end
state :carrier_details_collected, :human_name => 'Resolution' do
end
state :closed, :human_name => 'Closed' do
end
end
end
Ticket.human_state_name(:issue_details_collected) # => "Carrier Details"
ticket = Ticket.new # => #<Ticket:0x87c6e1c>
ticket.state = 'new' # => "new"
ticket.next_step # => true
Ticket.human_state_name(:issue_details_collected) # => "Carrier Details"
If you could provide a reproducible example or ensure that no other code is referencing the human name value, that'd be great. There's really nothing special that state_machine is doing with that string under the hood.
Here's the example repo: https://github.com/iabdulin/state_machine_human_name_issue
@iabdulin Awesome find... looks like it has to do with the ActiveModel integration assuming that you'll be specifying the human name option in the locale. I'll look into fixing this over the next week or so.
I've updated the repo with another test. There are 2 models Ticket and Ticket2, both in ticket.rb. The only diff between classes is order of defining event and states. But the behaviour is different. Run Ticket.test in console.
Just FYI -- haven't forgotten about this .. just been a little busy lately.
cool
is solution ready?
In Ticket.rb I have
In console:
What's wrong?