-
Notifications
You must be signed in to change notification settings - Fork 513
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
human_name is ignored in ActiveRecord #260
Comments
Could you give a little more context? Using version 1.2.0 this looks to be working with ActiveRecord. Also, just to make sure, class Vehicle
state_machine :alarm_state, :initial => :active, :namespace => 'alarm' do
....
end
end your call would be something like: vehicle = Vehicle.new
vehicle.human_alarm_state_name Could this be the issue? |
No, I tried that, basically here is the issue. In an ActiveRecord Model, I specify the following: state_machine :send_status, :initial => :not_sent do
state :not_sent, :value => 0, :human_name => lambda{self.scheduled_date.nil? ? 'Not Scheduled' : "Scheduled #{self.scheduled_date}"}
state :sent, :value => 1, :human_name => lambda {"Sent #{self.sent_date}"}
state :rejected, :value => 2, :human_name => 'Rejected'
end When I do It seems to only be affecting ActiveRecord models as if I create a Dummy class model like you did in the example, everything seems to work. |
Ah I see, that is pretty different from what I thought you were asking : ). I think the problem may be that the The problem from looking through the source of that class is that there is no way to get the current instance of the object that you are calling state_machine :send_status, :initial => :not_sent do
state :not_sent, :value => 0 do
def human_send_status_name
self.scheduled_date.nil? ? 'Not Scheduled' : "Scheduled #{self.scheduled_date}"
end
end
state :sent, :value => 1 do
def human_send_status_name
"Sent #{self.sent_date}"
end
end
state :rejected, :value => 2, :human_name => 'Rejected'
end This returns the context of |
Even if I remove the lambda, and use a static string as in the case of |
When using ActiveRecord the
human_name
option is ignored.The text was updated successfully, but these errors were encountered: